我添加了控制
if (e.Row.RowType == DataControlRowType.DataRow)
{
CheckBox chk = new CheckBox();
chk.EnableViewState = true;
chk.Enabled = true;
chk.ID = "chkb";
DataRowView dr = (DataRowView)e.Row.DataItem;
chk.Checked = (dr[0].ToString() == "true");
e.Row.Cells[1].Controls.Add(chk);
e.Row.TableSection = TableRowSection.TableBody;
}
并试图通过
if (GridView2.Rows.Count>0)
{
foreach (GridViewRow row in GridView2.Rows)
{
CheckBox cb =(CheckBox) GridView2.Rows[2].Cells[1].FindControl("chkb");
if (cb != null && cb.Checked)
{
Response.Write("yest");
}
}
}
但我找不到它......实际上我的问题是我需要创建一个动态列表..为此我正在使用gridview