Posted on: 11/15/2014 11:41:46 AM | Views : 430

Hello Guys ! I would like to checked/unchecked  check box on behalf of db records but that check box is in  grid view and that grid view is in Data List. the Issue is
Object reference not set to an instance of an object. Line 26: foreach (GridViewRow gvrow in gvRoles.Rows) Here is the code :
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { string userName = DropDownList1.SelectedItem.Text; string[] userRoles = Roles.GetRolesForUser(userName); string rolename = string.Empty; GridView gvRoles = ((GridView)DataList1.FindControl("GridView1")); gvRoles.DataBind(); foreach (GridViewRow gvrow in gvRoles.Rows) { CheckBox chk = (CheckBox)gvrow.FindControl("chkRole"); Label lbl = (Label)gvrow.FindControl("lblRole"); rolename = lbl.Text; int index = Array.I ...

Go to the complete details ...