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) { try { 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); dtGetStTable.Rows[i].Delete(); dtGetStTable.AcceptChanges(); } catch (Exception ex) { //throw; } } }
This Blog is a programing portal, with tutorials and references relating to development subjects, including C#,Silverlight,WCF, Asp.Net,HTML, XML, CSS, JavaScript,Sql, Windows Administration.
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.
Subscribe to:
Post Comments (Atom)
Join the top Python Training in Hyderabad at AI Patasala and take your career to an entirely new level in the field.
ReplyDeleteAI Patasala Python Course