I have used template CheckBox in gridview for multiple rows deletion, when I select multiple rows by selecting the CheckBox and perform the delete operation it seems to be selected CheckBox is not returning true on the code below.
protected void Button6_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
LinkButton ch = new LinkButton();
ch = (LinkButton)row.FindControl("l1");
id = Convert.ToInt16(ch.CommandArgument);
CheckBox chs = new CheckBox();
chs = ((CheckBox)row.FindControl("c1"));
if (chs.Checked == true)
{
DeleteSelected(id);
}
}
}
private void DeleteSelected(short id)
{
var ch = from a in empd.Employees where (a.ID == id) select a;
empd.Employees.DeleteAllOnSubmit(ch);
empd.SubmitChanges();
display_emp();
}
Well now I have fixed the connection everything, please just refresh the database.Please get the web application in the below link.
Please help me on why selected checkbox are not returning true in the code.
Neha SharmaPosted Oct 26, 2012, 7:26 AM
Your given webapplication is not working properly when i click on delete button it's doing nothing,you can go through with the below link:
http://csharpdotnetfreak.blogspot.com/2009/04/delete-multiple-rows-gridview-checkbox.html
The same you wanna do,if it helps you mark it as answer if not let me know the issue please.
Note:Without breakpoint i am unable to know what is the issue here in your code,if you can do in your side please add breakpoint and debug your code you ll come to know what is the actually problem with code,othervice you can go through with the given link solution.