How to show an empty GridView when DataSet is datasource?


J

JB

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
 
Ad

Advertisements


Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top