Reputation: 171
I have the bellow Gridview
that pulls data from a stored procedure
that turns the data from vertical to horizontal with a pivot. I want to add a new row at a specific RowNumber 5
. This row will be filled only with black color.
<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>
Upvotes: 0
Views: 410
Reputation: 1593
You have a similar question to these. Have a look on them
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();
Upvotes: 1
Reputation: 924
Do something like this:
DataRow dr = DataTable.NewRow();
DataTable.Rows.InsertAt(dr, 5);
DataTable.AcceptChanges();
gv_list.DataSource = DataTable;
gv_list.DataBind();
Upvotes: 0