.net2.0中如何得到gridview中动态添加的模板列中checkbox控件是否选择
public class MutiSelectTemplate : ITemplate
{
public MutiSelectTemplate(DataControlRowType type)
{
//
// TODO: 在此处添加构造函数逻辑
//
}
private DataControlRowType templateType;
#region ITemplate 成员
public void InstantiateIn(Control container)
{
if (templateType == DataControlRowType.DataRow)
{
CheckBox checkbox = new CheckBox();
checkbox.ID = "SelectMutiWTD ";
container.Controls.Add(checkbox);
}
}
#endregion
}
protected void Page_Load(object sender, EventArgs e)
{
BindGridViewCell(GridView1);
}
private void BindGridViewCell(GridView gridView)
{
......
TemplateField templateField = new TemplateField();
templateField.HeaderText = "选择 ";
templateField.ItemTemplate = new MutiSelectTemplate();
gridView.Columns.Add(templateField);
}
//点击保存按钮的时候从gridview中得到所有行,判断是否选择
protected void SaveButtonClick(object sender, EventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)