i have editable grid view which have check boxes which binded with data row. here i put code :
protected void GV_ViewCustomers_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowState != DataControlRowState.Edit)
{
using (DataClassesDataContext db = new DataClassesDataContext())
{
DropDownList ddl = (DropDownList)e.Row.FindControl("DDL_Types");
ddl.DataSource = db.PartyTypes.Select(p => p).ToList();
ddl.DataBind();
ddl.SelectedValue = DataBinder.Eval(e.Row.DataItem, "type_id").ToString();
DropDownList ddl1 = (DropDownList)e.Row.FindControl("DDL_CountryNames");
ddl1.DataSource = db.Countries.Select(c => c).ToList();
ddl1.DataBind();
if (!string.IsNullOrEmpty(DataBinder.Eval(e.Row.DataItem, "country_id").ToString()))
{
ddl1.SelectedValue = DataBinder.Eval(e.Row.DataItem, "country_id").ToString();
DropDownList ddl2 = (DropDownList)e.Row.FindControl("DDL_StateNames");
ddl2.DataSource = db.States.Where(s => s.country_id.Equals(int.Parse(DataBinder.Eval(e.Row.DataItem, "country_id").ToString()))).Select(s => s).ToList();
ddl2.DataBind();
ddl2.SelectedValue = DataBinder.Eval(e.Row.DataItem, "state_id").ToString();
}
}
DataRowView rowView1 = (DataRowView)e.Row.DataItem;
if (rowView1["UserOFC"] != null)
{
(e.Row.FindControl("chk_UserOFC") as CheckBox).Checked = Convert.ToBoolean(e.Row.DataItem.Equals("UserOFC").ToString());
}
if (rowView1["UserVAT"] != null)
{
(e.Row.FindControl("chk_UserVAT") as CheckBox).Checked = Convert.ToBoolean(e.Row.DataItem.Equals("UserVAT").ToString());
}
if (rowView1["UserINV"] != null)
{
(e.Row.FindControl("chk_UserINV") as CheckBox).Checked = Convert.ToBoolean(e.Row.DataItem.Equals("UserINV").ToString());
}
if (rowView1["UserNone"] != null)
{
(e.Row.FindControl("chk_UserNone") as CheckBox).Checked = Convert.ToBoolean(e.Row.DataItem.Equals("UserNone").ToString());
}
}
}
this all check boxes values coming from allow null data column so there need to bind them from grid view row data bound.