Hello,
I'm trying to delete a row from my gridview which seems to work fine, but it doesn't actually delete the row. The code below actually finds the correct row and does the DeleteRow method with no problem. But it doesn't refresh the grid. How can I refresh the grid? I did a DataBind() again, but then it had nothing in it. While I'm looping thru the rows and I actually call the DeleteRow method, I check the count of the rows and the count stays the same. What am I missing?
Thanks in advance.
I'm trying to delete a row from my gridview which seems to work fine, but it doesn't actually delete the row. The code below actually finds the correct row and does the DeleteRow method with no problem. But it doesn't refresh the grid. How can I refresh the grid? I did a DataBind() again, but then it had nothing in it. While I'm looping thru the rows and I actually call the DeleteRow method, I check the count of the rows and the count stays the same. What am I missing?
Thanks in advance.
Code:
foreach (GridViewRow row in GridView1.Rows)
{
if (accountId == row.Cells[1].Text)
{
GridView1.DeleteRow(row.RowIndex);
}
}
protected void GridView1_OnRowDeleting(object sender, EventArgs e)
{
}