How to correctly configure a GridView?

Gridview is not appearing.What is my mistake?

  • With the WHERE clause, the gridview is not appearing and without it, it is appearing? Why is it so? This is my code. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="daily_report_console.aspx.vb" Inherits="daily_report_console" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-… <html> <head> <title>Daily Report</title> <style type="text/css"> .style1 { width: 404px; } </style> </head> <body> <form id="form1" runat="server"> <center> <table border="2" cellspacing="0" cellpadding="30" width="" style="border-color:#336699"> <tr> <td align="center" class="style1"> <table border="0" cellspacing="0" cellpadding="10"> <td><img src="image/DRC.jpg" alt="Extolcorp MSC Bhd" /></td> </tr> <tr> <td><center> <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="White" BorderWidth="1px" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="190px" NextPrevFormat="FullMonth" Width="350px"> <DayHeaderStyle Font-Bold="True" Font-Size="8pt" /> <NextPrevStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333" VerticalAlign="Bottom" /> <OtherMonthDayStyle ForeColor="#999999" /> <SelectedDayStyle BackColor="#333399" ForeColor="White" /> <TitleStyle BackColor="White" BorderColor="Black" BorderWidth="4px" Font-Bold="True" Font-Size="12pt" ForeColor="#333399" /> <TodayDayStyle BackColor="#CCCCCC" /> </asp:Calendar> </td> </center> </tr> <tr> <td> <asp:Button ID="Button1" runat="server" Text="Back" Width="95px" />&nbsp <asp:TextBox ID="TextBox1" runat="server">Select Date</asp:TextBox>&nbsp <asp:Button ID="Button2" runat="server" Text="Get Report" Width="95px"/> </td> </tr> </table> </table> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" Visible="False"> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:guestConnectionString2 %>" ProviderName="<%$ ConnectionStrings:guestConnectionString2… %>" SelectCommand="SELECT id, date, f_name, l_name, person_2_meet, time_entered, time_exited, email FROM guest WHERE DATE(date) = DATE(NOW())"> <SelectParameters> <asp:ControlParameter ControlID="TextBox1" DefaultValue="%" Name="date" PropertyName="Text" Type="String" /> </SelectParameters> </asp:SqlDataSource> </form> </body> </html>

  • Answer:

    With your WHERE clause, your query may be returning no results, so the gridview hides itself. You could add an empty row if you want to force it be visible.

Blaze at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.