到达转发器项目:The Logic
Reaching repeater item: The Logic
这是我的设计页面:
<asp:MultiView ID="mvProducts" runat="server" ActiveViewIndex="0">
<asp:View runat="server" ID="mvProducts1">
<asp:Repeater ID="rptDiscount" runat="server">
<ItemTemplate>
<div class="divProduct1">
<div class="divProductHeader">
<asp:Panel ID="pnlDiscount" runat="server" CssClass="divProductHeaderDiscount" Visible="true">
<div class="menuTextTopSpacer"></div>
<asp:Label ID="lblDiscount" runat="server" Text='<%#Eval("discount") %>'></asp:Label>
</asp:Panel>`
我只想访问 pnlDiscount
项,但我不知道如何访问。我进行了搜索,但这只会让我更加困惑。
确实,我想学习在中继器中找到控件的逻辑。
使用ItemDataBound on your reapter then use FindContol()到达Panel
protected void rptDiscount_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Panel myPanel= e.Item.FindControl("pnlDiscount") as Panel;
//Do some work
}
这是我的设计页面:
<asp:MultiView ID="mvProducts" runat="server" ActiveViewIndex="0">
<asp:View runat="server" ID="mvProducts1">
<asp:Repeater ID="rptDiscount" runat="server">
<ItemTemplate>
<div class="divProduct1">
<div class="divProductHeader">
<asp:Panel ID="pnlDiscount" runat="server" CssClass="divProductHeaderDiscount" Visible="true">
<div class="menuTextTopSpacer"></div>
<asp:Label ID="lblDiscount" runat="server" Text='<%#Eval("discount") %>'></asp:Label>
</asp:Panel>`
我只想访问 pnlDiscount
项,但我不知道如何访问。我进行了搜索,但这只会让我更加困惑。
确实,我想学习在中继器中找到控件的逻辑。
使用ItemDataBound on your reapter then use FindContol()到达Panel
protected void rptDiscount_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
Panel myPanel= e.Item.FindControl("pnlDiscount") as Panel;
//Do some work
}