How can I delete a specified row from a DataTable
and then reload a ViewState
with the rest of the rows left? I have the following case below, but I am not able to delete directly from DataTable
.
protected void rdItens_DeleteCommand(object sender, GridCommandEventArgs e)
{
string ID = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString();
DataTable table = (DataTable)ViewState["ItensGrid"];
var linha = table.Rows.Find(ID);
linha.Delete();
ViewState["ItensGrid"] = table;
}