I spotted that you are hiding the gridview when there are no rows to display so you don't need to do all the for loops and the binding in case of an empty cart. So if
objDT.Rows.Count
is zero you can go immeadiately to the part where you are hiding the gridview and
do the other stuff only when there is something
I in your cart.
Modification:
OMG, I found the solution to your problem on MSDN. After the Delete call on the row you also have to call AcceptChanges(). Only then will the row really be removed from the table.
for (int i = rowCount - 1; i >= 0; i--)
{
CheckBox cbDelete = (CheckBox)gvCart.Rows[i].Cells[0].FindControl("chkDelete");
if (cbDelete.Checked)
{
objDT.Rows[i].Delete();
objDT.Rows[i].AcceptChanges();
}
}
The above code should solve your issue.
End modification
Regards,
Manfred