Social Icons

Thursday, January 26, 2012

Getting checkbox selected Gridview Rows in ASP.Net

Following is the line of code use to get the checked box selected rows of grid and getting the columns values from the gridview source DataTable.
DataTable dtGetStTable = (DataTable)ViewState["dtNewStudents"];

//Looping throgh Grid and deleting row after finding the checked row
for (int i = dtGetStTable.Rows.Count - 1; i > -1; i--)
    GridViewRow row = GridView1.Rows[i];
    bool isChecked = ((CheckBox)row.FindControl("CheckBox1")).Checked;

    if (isChecked)
            string RollNo = dtGetStTable.Rows[i]["RollNo"].ToString();
            string Class = dtGetStTable.Rows[i]["Class"].ToString();
            string Division = dtGetStTable.Rows[i]["Division"].ToString();
            //Deleting the Reocrd from DataBase
            TotalRecordDeleted += objSRE.DeleteTheSelectedRecord(RollNo, Class, Division);

        catch (Exception ex)


No comments:

Post a Comment


Sample text

Sample Text