GridView在后台动态生成了一列CheckBox的模板列,该如何实现CheckBox的单选 ?
动态生成CheckBox模板列
public class CheckBoxTemplate : ITemplate
{ #region ITemplate 成员 public void InstantiateIn(Control container)
{
CheckBox cb = new CheckBox();
cb.ID = "checkOne";
cb.AutoPostBack = true;
cb.DataBinding += new EventHandler(cb_DataBinding);
container.Controls.Add(cb);
} void cb_DataBinding(object sender, EventArgs e)
{
CheckBox cb = (CheckBox)sender;
GridViewRow container = (GridViewRow)cb.NamingContainer;
}
void cb_CheckOne(object sender, EventArgs e)
{ } #endregion
}
动态生成CheckBox模板列
public class CheckBoxTemplate : ITemplate
{ #region ITemplate 成员 public void InstantiateIn(Control container)
{
CheckBox cb = new CheckBox();
cb.ID = "checkOne";
cb.AutoPostBack = true;
cb.DataBinding += new EventHandler(cb_DataBinding);
container.Controls.Add(cb);
} void cb_DataBinding(object sender, EventArgs e)
{
CheckBox cb = (CheckBox)sender;
GridViewRow container = (GridViewRow)cb.NamingContainer;
}
void cb_CheckOne(object sender, EventArgs e)
{ } #endregion
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货