Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to enable to view the grid view header even the grid view datasource is empty. I am using dotnet framework3.5.

XML
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                                DataSourceID="odsAccountOpening" EnableModelValidation="True" Height="135px"
                                Width="942px">
                                <Columns>
                                    <asp:BoundField DataField="AccountNo" HeaderText="Account No"
                                        SortExpression="AccountNo" />
                                    <asp:BoundField DataField="SycDepositTypeId" HeaderText="Deposit Type"
                                        SortExpression="SycDepositTypeId" />
                                        <%--<asp:TemplateField HeaderText="Deposit Type">
                                        <ItemTemplate>
                                            <asp:Label ID="lblDepositType1" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.SycDepositType.DepositTypeName") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>--%>
                                    <asp:BoundField DataField="MamAccountHolderTypeId" HeaderText="Account Type"
                                        SortExpression="MamAccountHolderTypeId" />
                                    <asp:BoundField DataField="InterestRate" HeaderText="Interest Rate"
                                        SortExpression="InterestRate" />
                                    <asp:BoundField DataField="AccountOpenOnBs" HeaderText="A/C Opened On"
                                        SortExpression="AccountOpenOnBs" />
                                    <asp:BoundField DataField="MaturityOn" HeaderText="Maturity On"
                                        SortExpression="MaturityOn" />
                                    <asp:BoundField DataField="MamAccountStatusId" HeaderText=" Account Status "
                                        SortExpression="MamAccountStatusId" />
                                </Columns>
                            </asp:GridView>
                            <asp:ObjectDataSource ID="odsAccountOpening" runat="server"
                                OldValuesParameterFormatString="original_{0}"
                                onobjectcreating="odsAccountOpening_ObjectCreating" SelectMethod="GetAll"
                                TypeName="MemberAccountManagement.BLL.CMamAccountOpening">
                            </asp:ObjectDataSource>
Posted
Updated 27-Oct-13 21:18pm
v2

Hello User,

Set the ShowHeaderWhenEmpty property to true.

Regards,
 
Share this answer
 
Comments
Thanks7872 28-Oct-13 3:30am    
To the point. Pretty straight forward. +5.
Prasad Khandekar 28-Oct-13 3:48am    
Thank's Rohan.
 
Share this answer
 
ShowHeaderWhenEmpty="True"

This is the solution for showing header when datasource is empty

Or else you can use Listview.

Hope This helps!!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900