Last post Nov 14, 2018 02:35 AM by oned_gk
Nov 13, 2018 01:50 AM|shsu|LINK
I have a gridview in my asp.net webpage.
I could show the header even if there is no values in grid viee by showheaderwhen Empty to True.
When I laod the page ,the header is not showing ,If I click on a button or change the dropdownlist value,,then only the empty header is showing. How can I show an empty gridview header while page loading time? Appreciate the help
Nov 14, 2018 02:22 AM|Ackerly Xu|LINK
You say you could show the header when set ShowHeaderWhenEmpty to true.
After, you say when you load page , the header is not showing.
I have made a test .When setting ShowHeaderWhenEmpty to true,it shows header well.
Below is my code.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" DataKeyNames="item_id" DataSourceID="SqlDataSource1" ShowHeaderWhenEmpty="true" >
<asp:BoundField DataField="item_id" HeaderText="item_id" InsertVisible="False" ReadOnly="True" SortExpression="item_id" />
<asp:BoundField DataField="item_name" HeaderText="item_name" SortExpression="item_name" />
<asp:BoundField DataField="content" HeaderText="content" SortExpression="content" />
If it is not your case, could you show your sample code to let us reproduce your problem?
Nov 14, 2018 02:35 AM|oned_gk|LINK
I guess you need to provide datasource and call databind in not ispostback page_load, because the datasource containing column names.
Or like another post, you can add columns manualy