如何在asp网格的表格顶部添加新行

时间:2014-11-20 14:12:40

标签: c# asp.net

我在这里向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();

1 个答案:

答案 0 :(得分:1)

你可以尝试这个:

dtCurrentTable.Rows.InsertAt(drCurrentRow, 0);