当数据中没有数据时如何显示GridView页脚行 [英] How to show gridview footer row when no data present in datasorce

查看:72
本文介绍了当数据中没有数据时如何显示GridView页脚行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好......

我的页面上有一个网格视图,并且已使用网格视图的页脚行插入新数据.我面临的问题是,当数据库中没有数据时,它没有显示网格视图.但是我需要在页面上显示网格视图,以便用户可以输入数据.请帮帮我.

Hello all....

I have a grid-view on my page and i have used footer row of grid-view to insert new data. The problem that i am facing is that is when there is no data present in the database it is not showing grid-view. But i need grid-view to be shown on the page so that user can enter data. Please help me out.

<asp:GridView DataKeyNames="ID" ID="Grid_Categories" runat="server" AutoGenerateColumns="False"

        Width="250px" onrowcancelingedit="Grid_Categories_RowCancelingEdit"

        onrowdeleting="Grid_Categories_RowDeleting"

        onrowediting="Grid_Categories_RowEditing"

        onrowupdating="Grid_Categories_RowUpdating"

        onselectedindexchanged="Grid_Categories_SelectedIndexChanged"

        onrowcommand="Grid_Categories_RowCommand" ShowFooter="True"

        onrowdatabound="Grid_Categories_RowDataBound" EmptyDataText="no valyue">

    <Columns>
    <asp:TemplateField ItemStyle-Width="165">
    <ItemTemplate>
    <asp:LinkButton runat="server" ID="link_category" Text='<%# Eval("Category") %>' CommandName="Select" CausesValidation="true"></asp:LinkButton>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox runat="server" ID="txtcategory" Text='<%# Eval("Category") %>'></asp:TextBox>
    </EditItemTemplate>

    <FooterTemplate>
    Name &nbsp;&nbsp;
    <asp:TextBox runat="server" ID="txtnewcategory"></asp:TextBox>
    </FooterTemplate>

<ItemStyle Width="165px"></ItemStyle>
    </asp:TemplateField>
    <asp:TemplateField>

    <ItemTemplate>
    <asp:LinkButton runat="server" ID="link_Edit" Text="Edit" CommandName="Edit" CausesValidation="true"></asp:LinkButton>
    &nbsp;&nbsp;
    <asp:LinkButton runat="server" ID="link_Delete" Text="Delete" CommandName="Delete" CausesValidation="true"></asp:LinkButton>
    </ItemTemplate><pre lang="c#">
    <EditItemTemplate>
    <asp:LinkButton runat="server" ID="link_Update" Text="Update" CommandName="Update" CausesValidation="true"></asp:LinkButton>
    &nbsp;&nbsp;
    <asp:LinkButton runat="server" ID="link_Cancel" Text="Cancel" CommandName="Cancel" CausesValidation="true"></asp:LinkButton>
    </EditItemTemplate>
    <FooterTemplate>
    <asp:Button runat="server" ID="btn_insert1" Text="Insert" CommandName="Insert" CausesValidation="true" />
    </FooterTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>

推荐答案



您可以创建 EmptyDataTemplate 用于显示页眉/页脚没有数据.

您可以在此模板内传递整个HTML表.

希望对您有帮助

谢谢
-amit.
Hi,

you can create EmptyDataTemplate for display header/footer when no data exist.

you can pass whole HTML table inside this template.

hope this will help you

thanks
-amit.


这篇关于当数据中没有数据时如何显示GridView页脚行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆