我有下面的Gridview
从stored procedure
中提取数据,该数据通过数据透视将数据从垂直变为水平。我想在特定RowNumber 5
添加新行。此行仅使用黑色填充。
<asp:GridView ID="GridView1" runat="server" OnRowCommand="GridView1_RowCommand" ShowHeader="true" CssClass="style3" ForeColor="White"
OnRowDataBound="GridView1_RowDataBound" DataSourceID="SqlDataSource1">
<EditRowStyle BorderColor="Black" ForeColor="Black" />
<Columns>
<asp:ButtonField CommandName="ColumnClick" Visible="false" />
</Columns>
</asp:GridView>
答案 0 :(得分:1)
你有类似的问题。 看看他们
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/3cc334fb-9da0-48eb-b83e-0bec72c60d16 http://forums.asp.net/t/1670659.aspx/1
DataTable dt = GridView1.tables[0];
DataRow dr = new DataRow();
DataTable.Rows.InsertAt(dr, 5);
DataTable.AcceptChanges();
gv_list.DataSource = dt;
gv_list.DataBind();
答案 1 :(得分:0)
做这样的事情:
DataRow dr = DataTable.NewRow();
DataTable.Rows.InsertAt(dr, 5);
DataTable.AcceptChanges();
gv_list.DataSource = DataTable;
gv_list.DataBind();