How to show an empty GridView when DataSet is datasource?

Discussion in 'ASP .Net' started by JB, Sep 21, 2009.

  1. JB

    JB Guest

    Hello

    The datasource for my GridView is a DataSet. When the C# ASP.NET web
    page first comes up an empty GridView should appear and then when based on
    what selection the user is makes on a different control on the web page then
    the GridView will be populated. My question is:

    Using this DataSet how can I show an empty GridView when the web page shows?

    <asp:GridView ID="PGrid" AllowPaging="True" BorderStyle="Solid"
    OnPageIndexChanging="PGrid_PageIndexChanged" PageSize="5" Height="50px"
    Width="1100px"
    AutoGenerateColumns="False" runat="server"
    onrowdatabound="PGrid_RowDataBound" >
    <Columns>
    <asp:TemplateField HeaderText="PID#" SortExpression="PID">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox1" runat="server" Text='<%#
    Bind("PID") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label1" runat="server" Text='<%#
    Bind("PID") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="C Type" SortExpression="CID">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox2" runat="server" Text='<%#
    Bind("CID") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label2" runat="server" Text='<%#
    Bind("CID") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="Coming" SortExpression="Coming">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox3" runat="server" Text='<%#
    Bind("Coming") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label3" runat="server" Text='<%#
    Bind("Coming") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="Going" SortExpression="Going">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox4" runat="server" Text='<%#
    Bind("Going") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label4" runat="server" Text='<%#
    Bind("Going") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="Desc" SortExpression="Desc">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox5" Wrap="true"
    TextMode="MultiLine" runat="server" Text='<%# Bind("Pro") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label5" runat="server" Text='<%#
    Bind("Pro") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="Comments"
    SortExpression="IComments">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox6" Wrap="true"
    TextMode="MultiLine" runat="server"
    Text='<%# Bind("IComments") %>'> </asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label6" runat="server" Text='<%#
    Bind("IComments") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="C Date Time" SortExpression="C
    Date Time">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox7" runat="server" Text='<%#
    Bind("CDateTime", "{0:M-dd-yyyy}" ) %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label7" runat="server" Text='<%#
    Bind("CDateTime") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="Dpatch Date Time"
    SortExpression="Dpatch Date Time">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox8" runat="server"
    Text='<%# Bind("DDateTime") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label8" runat="server" Text='<%#
    Bind("DDateTime") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    <asp:TemplateField HeaderText="R Date Time"
    SortExpression="R Date Time">
    <EditItemTemplate>
    <asp:TextBox ID="TextBox9" runat="server"
    Text='<%# Bind("RDateTime") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="Label9" runat="server" Text='<%#
    Bind("RDateTime") %>'></asp:Label>
    </ItemTemplate>

    </asp:TemplateField>
    </Columns>
    </asp:GridView>

    JB
    --
    JB
     
    JB, Sep 21, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGFiYmxlcg==?=

    show header when gridview is empty

    =?Utf-8?B?RGFiYmxlcg==?=, Mar 30, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    22,022
    thienle282
    Jan 13, 2012
  2. Replies:
    0
    Views:
    2,120
  3. Bren
    Replies:
    3
    Views:
    7,744
  4. Eric Effer

    Dataset as datasource in Gridview

    Eric Effer, Jan 25, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    654
    Masudur
    Jan 25, 2007
  5. Savvoulidis Iordanis

    Empty gridview cells and checking for empty string

    Savvoulidis Iordanis, Sep 5, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    548
    Savvoulidis Iordanis
    Sep 5, 2008
Loading...

Share This Page