我在这里向dataTable添加了一个新行。有没有办法在表格的顶部添加新行而不是在底部。
DataTable dtCurrentTable = (DataTable)Session["dsRAComponent"];
DataRow drCurrentRow;
drCurrentRow = dtCurrentTable.NewRow();
drCurrentRow["MODELNO"] = String.Empty;
drCurrentRow["MODELDESC"] = String.Empty;
drCurrentRow["QTY"] = 0;
dtCurrentTable.Rows.Add(drCurrentRow);
Session["dsRAComponent"] = dtCurrentTable;
//Rebind the Grid with the current data
gvReceivedComponent.DataSource = dtCurrentTable;
gvReceivedComponent.DataBind();
答案 0 :(得分:1)
你可以尝试这个:
dtCurrentTable.Rows.InsertAt(drCurrentRow, 0);