Manually add checkbox into GridView:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
System.Data.DataTable dt = GetTable();
ViewState["dt"] = dt;
GridView1.DataSource = dt;
GridView1.DataBind();
}
AddCheckBox();
}
void AddCheckBox()
{
System.Data.DataTable dt = (System.Data.DataTable)ViewState["dt"];
for (int i = 0; i < dt.Rows.Count; i++)
{
if (GridView1.Rows[i].Cells[0].Controls.Count == 0)
{
CheckBox cb = new CheckBox();
GridView1.Rows[i].Cells[0].Controls.Add(cb);
}
}
}
void GetCheckBoxValue()
{
foreach (GridViewRow gr in GridView1.Rows)
{
bool cbValue = ((CheckBox)gr.Cells[0].Controls[0]).Checked;
}
}