repeater嵌套取值问题,急用!!!
我在repeater中嵌套了一个checkboxlist控件,现在我要取得checkboxlist的选中值,该如何实现,大家帮忙看看。非常感谢。相关代码:前台:
<asp:Repeater ID="repposition" runat="server"
onitemdatabound="repposition_ItemDataBound">
<ItemTemplate>
<asp:HiddenField ID="hidshow" runat="server" Value='<%#Eval("showID") %>' />
<span style="border: 0px solid #325FB5; background-color: #F1F6FC; font-size:16px; font-weight:bold;">
<%#Eval("showExplain")%></span>
<asp:CheckBoxList ID="chkPostion" runat="server" RepeatColumns="4" RepeatDirection="Horizontal" AutoPostBack="true"
Width="623px">
</asp:CheckBoxList>
</ItemTemplate>
</asp:Repeater>
后台:
private void BindFpoistion()
{
WT.BLL.ShowPosition bll_sp = new WT.BLL.ShowPosition();
repposition.DataSource = bll_sp.GetList(" fatherID=0");
repposition.DataBind();
}
protected void repposition_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
WT.BLL.ShowPosition bll_sp = new WT.BLL.ShowPosition();
CheckBoxList cbl;
int id;
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
cbl = (CheckBoxList)e.Item.FindControl("chkPostion");
id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidshow")).Value);
cbl.DataSource = bll_sp.GetList(" fatherID=" + id);
cbl.DataValueField = "showID";
cbl.DataTextField = "showExplain";
cbl.DataBind();
string postion = "";
for (int y = 0; y < cbl.Items.Count; y++)
{
if (cbl.Items[y].Selected)
{
postion += cbl.Items[y].Value + ",";
}
}
ViewState["position"] = postion;
}
}
红色部分是我尝试弄的,不好使,大家看一下,推荐一下实现方法。非常感谢!