asp.net Repeater控件嵌套Repeater问题
Repeater2嵌套Repeater1里.内含<checkbox>控件,代码如下:<asp:RepeaterID="Rep_modeId"runat="server"O...
Repeater2嵌套Repeater1里.内含<checkbox>控件,代码如下:
<asp:Repeater ID="Rep_modeId" runat="server" OnItemDataBound="Rep_modeId_ItemDataBound">
<ItemTemplate>
<li>
<b><%# Eval("mname") %></b>
<asp:Repeater runat="server" ID="Rep_sonId">
<HeaderTemplate>
<ul style="padding-right: 0px; padding-left: 0px; font-size: 13px; padding-bottom: 0px; margin: 0px; padding-top: 0px; list-style-type: none">
</HeaderTemplate>
<ItemTemplate>
<li style="margin-left:25px;">
<asp:CheckBox ID="cb_sonid" runat="server" />
<asp:HiddenField ID="hi_sonid" runat="server" Value='<%#Eval("mfather") %>' /><%# Eval("mname") %>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</li>
</ItemTemplate>
</asp:Repeater>
后台代码:
string[] Purv = result.Split(',');
foreach (RepeaterItem ri in this.Rep_modeId.Items) {
Repeater Rep_son = (Repeater)ri.FindControl("Rep_sonId");
foreach (RepeaterItem sonri in Rep_son.Items) {
HiddenField hf = (HiddenField)sonri.FindControl("hi_sonid");
CheckBox cb = (CheckBox)sonri.FindControl("cb_sonid");
foreach (string str in Purv) {
if (hf.Value == str) {
cb.Checked = true;
}
}
}
}
为什么给内嵌checkbox附ture.前台不勾选? cb.Checked = true;请高手.给我解决一下.谢谢 展开
<asp:Repeater ID="Rep_modeId" runat="server" OnItemDataBound="Rep_modeId_ItemDataBound">
<ItemTemplate>
<li>
<b><%# Eval("mname") %></b>
<asp:Repeater runat="server" ID="Rep_sonId">
<HeaderTemplate>
<ul style="padding-right: 0px; padding-left: 0px; font-size: 13px; padding-bottom: 0px; margin: 0px; padding-top: 0px; list-style-type: none">
</HeaderTemplate>
<ItemTemplate>
<li style="margin-left:25px;">
<asp:CheckBox ID="cb_sonid" runat="server" />
<asp:HiddenField ID="hi_sonid" runat="server" Value='<%#Eval("mfather") %>' /><%# Eval("mname") %>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</li>
</ItemTemplate>
</asp:Repeater>
后台代码:
string[] Purv = result.Split(',');
foreach (RepeaterItem ri in this.Rep_modeId.Items) {
Repeater Rep_son = (Repeater)ri.FindControl("Rep_sonId");
foreach (RepeaterItem sonri in Rep_son.Items) {
HiddenField hf = (HiddenField)sonri.FindControl("hi_sonid");
CheckBox cb = (CheckBox)sonri.FindControl("cb_sonid");
foreach (string str in Purv) {
if (hf.Value == str) {
cb.Checked = true;
}
}
}
}
为什么给内嵌checkbox附ture.前台不勾选? cb.Checked = true;请高手.给我解决一下.谢谢 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询