I have a datatable that I'm using as a shopping cart. I need to be able to remove rows from this datatable. I have an aspx page that displays the datatables contents and I have a button which I want the user to be able to click to remove that particular record. The button's CommandParameter is set to one of the other column's databound field. When the remove button is clicked I get the following error: "Input string was not in a correct format." My method is as follows:
protected void Button1_Click(object sender, EventArgs e)
{
int index = int.Parse(e.ToString());
DataTable tempTable = new DataTable();
tempTable = (DataTable)Session["Cart"];
tempTable.Rows[index].Delete();
Session["Cart"] = tempTable;
}
Thanks in advance.
protected void Button1_Click(object sender, EventArgs e)
{
int index = int.Parse(e.ToString());
DataTable tempTable = new DataTable();
tempTable = (DataTable)Session["Cart"];
tempTable.Rows[index].Delete();
Session["Cart"] = tempTable;
}
Thanks in advance.