veradistech
asked on
Datatable row deletion in Gridview
Hi,
I have a gridview, which is binded to datatable. I too have a checkbox in each row in gridview. Now, i would like to delete the selected rows by selecting the checkbox in button click event. I have tried as follows.
foreach (GridViewRow row in GridView1.Rows)
{
bool ischecked = ((CheckBox)row.FindControl ("chkDelet e")).Check ed;
if (ischecked == true)
{
row.Cells.Clear();
}
}
It worked fine.But, when i add a new row to gridview i see that the deleted rows are getting displayed back again. so, can anybody help me out to delete a row in datatable in gridview?
I have a gridview, which is binded to datatable. I too have a checkbox in each row in gridview. Now, i would like to delete the selected rows by selecting the checkbox in button click event. I have tried as follows.
foreach (GridViewRow row in GridView1.Rows)
{
bool ischecked = ((CheckBox)row.FindControl
if (ischecked == true)
{
row.Cells.Clear();
}
}
It worked fine.But, when i add a new row to gridview i see that the deleted rows are getting displayed back again. so, can anybody help me out to delete a row in datatable in gridview?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Am I wrong in thinking that there is no code in there to actually delete the row from the database, so when the control is re-bound the data will still appear?