GridView edit when bound toa Datatable

Telplovebeatt

New Member
I am creating a website where our customers can order parts directly from us. I have a datatable setup and when users click a button it adds a quick detail of the order to a gridview. In the gridview, I have the edit and delete buttons enabled. the delete function works fine, however when you try to edit the information, it doesn't change the gridview with the new info. Here's what I have so far:\[code\] protected void griditems_RowUpdating(object sender, GridViewUpdateEventArgs e) { DataTable dt = (DataTable)Session["table"]; foreach (DataRow dr in dt.Rows) { part = Convert.ToString(dr["Part"]); dr["Part"] = part; dr["Quantity"] = qty; dr["Ship-To"] = shipto; } griditems.EditIndex = -1; BindData(); }\[/code\]when trying this, it displays the gridview back with the original input values. I have also tried this (not working and get an error that says "There is no row at position 0":\[code\]DataTable dt = (DataTable)Session["table"];GridViewRow row = griditems.Rows[e.RowIndex];dt.Rows[row.DataItemIndex]["Part"] = ((TextBox)(row.Cells[1].Controls[0])).Text;dt.Rows[row.DataItemIndex]["Quantity"] = ((TextBox)(row.Cells[2].Controls[0])).Text;dt.Rows[row.DataItemIndex]["Ship-To"] = ((CheckBox)(row.Cells[3].Controls[0])).Checked;griditems.EditIndex = -1;BindData();\[/code\]Am I missing an EditItemTemplate in the aspx file, or am I just doing the RowUpdating all wrong?
 
Back
Top