我有一个ASP Repeater
包含标签列表的标签,我想看看哪个标签被选中(选中)。
喜欢:
<HeaderTemplate>
<ul class="tags-list">
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="tag" runat="server" AutoPostBack="true" Text='' />
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
我面临的问题是
protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container, Telerik.Sitefinity.Web.UI.ContentUI.Contracts.IContentViewDefinition definition)
方法在之前被触发并且:
void tagList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
var item = e.Item.DataItem as Taxon;
var checkbox = e.Item.FindControl("tag") as CheckBox;
checkbox.Text = item.Title;
checkbox.CheckedChanged += new EventHandler(this.checkbox_Changed);
}
}
每次在我的回调方法之前被解雇:
protected void checkbox_Changed(object sender, EventArgs e)
{
CheckBox tagCheckbox = (CheckBox)sender;
if (tagCheckbox.Checked)
{
}
}
谁能指导我获得复选框状态的最佳做法是什么?