问题
I need to add data to datatable and show it in a gridview. After entering each item, gridview should update automatically.
DataTable obj_dt_grdvw = new DataTable();
DataRow obj_dt_row = obj_dt_grdvw.NewRow();
obj_dt_grdvw.Columns.Add("_Pur_Product_Id", typeof(string));
obj_dt_grdvw.Columns.Add("Product_pur_Name", typeof(string));
obj_dt_row["_Pur_Product_Id"] = _Pur_Product_Id;
obj_dt_row["Product_pur_Name"] = Product_pur_Name;
obj_dt_grdvw.Rows.Add(obj_dt_row);
return obj_dt_grdvw;
After returning obj_dt_grdvw
, all the data gets erased automatically from datatable. I would like to delete the data manually.
来源:https://stackoverflow.com/questions/20583546/how-to-add-data-to-datatable-and-show-in-grid-view-c-sharp