Select and Delete Multiple Rows in Gridview control
How to Select and delete Multiple Rows of GridView using CheckBox
GridView Control allow to select only one row at a time but But a little logic is required to select more than one row or Multiple rows in GridView control. if we require to select Multiple row and delete them in a single click than we can do this by writing a little code.
In my example I am using CheckBox control of asp.net . A CheckBox control is added in every row of grid view ( using TemplateField) and any GridView row can be selected by selecting CheckBox control of that particular row.
Following sqlserver table (tbemp) is used in the example
Here is code for .aspx page
Code for .cs file (Replace the Page_Load event with following code)
In LinkButton3_Click event first we loop through each row of gridview and and then tested if they are selected (CheckBox checked) or not, the ‘Emp ID’ of each selected row is concatinated in a string variable named ‘d’ and passed as parameter in delete query “delete from tbemp where eno in("+d.ToString()+")"
Nice article....