Try setting a breakpoint right before you set those parameters and call the
grid's DataBind method and make sure that the code is running on the 1st
time you load the page, if it's running then set a watch or use the
immediate window to verify that you're actually setting the parameters to
the right values.
If you can't figure it out after than then post your code. Including the
ASPX.
I tried the breakpoint, and the code is getting executed, but nothing
it does shows up on the screen. even setting the label
'lbldebug.text' does not show up on the screen, though its value does
get set according to the debug window.
Here is the code - it is in a usercontrol.
Protected Sub btnGetData_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnGetData.Click
LoadGridView()
End Sub
Protected Sub LoadGridView()
Dim SQL As String = ""
Dim Dt As New Data.DataTable
Dim StartDate As Date = #1/1/1900#
Dim EndDate As Date = #1/1/1900#
Dim ReportName As String = ""
If IsDate(Me.txtStartDate.Text) Then
StartDate = Convert.ToDateTime(Me.txtStartDate.Text)
Else
Me.lblMessage.Text = "Enter a Start Date to Continue"
Exit Sub
End If
If IsDate(Me.txtEndDate.Text) Then
EndDate = Convert.ToDateTime(Me.txtEndDate.Text)
Else
Me.lblMessage.Text = "Enter an End Date to Continue"
Exit Sub
End If
If StartDate > EndDate Then
Me.lblMessage.Text = "Start Date Cannot Be GREATER than
End Date"
Exit Sub
End If
Dim strReportName As String
strReportName = Me.ddlReports.SelectedValue
If strReportName = "Select a Report" Then
Me.lblMessage.Text = "Select a Report to Continue!"
Exit Sub
End If
ReportName = GetsProcForReport()
lblDebug.Text = "strReportName is " & strReportName.ToUpper
If strReportName.ToUpper.Trim = "DAILY OUTREACH" Then
Delete3OutreachTablesUnusedRecords()
Session("DOStartDate") = Me.txtStartDate.Text
Session("DOEndDate") = Me.txtEndDate.Text
Session("DOAgencyName") =
Me.DropDownListAgencies.SelectedItem.Text
Me.SqlDataSourceDailyOutreachReport.DataBind()
Me.GridViewDailyOutreachReport2.DataBind()
Me.lblDebug.Text = Session("DOStartDate") & ", " &
Session("DOEndDate") & ", " & Session("DOAgencyName")
And here is the ascx code:
<asp:Label ID="lblDebug" runat="server" ForeColor="Lime"
Width="431px"></asp:Label>
<table>
<tr>
<td style="width: 3px">
<asp:Label ID="lblStartDate" runat="server"
Text="Start Date" Width="80px" ForeColor="Black"></asp:Label></td>
<td style="width: 3px">
<asp:TextBox ID="txtStartDate" runat="server"
Width="90px" BorderStyle="Groove"></asp:TextBox></td>
<td style="width: 3px">
<asp:ImageButton ID="imgStartDate" runat="server"
ImageUrl="~/images/Calendar_scheduleHS.bmp"
ValidationGroup="txtStartDate" /></td>
<td style="width: 3px">
<asp:Label ID="lblPholder1" runat="server"
ForeColor="White" Text="__"></asp:Label></td>
<td style="width: 3px">
<asp:Label ID="lblEndDate" runat="server"
ForeColor="Black" Text="End Date" Width="80px"></asp:Label></td>
<td style="width: 3px">
<asp:TextBox ID="txtEndDate" runat="server"
BorderStyle="Groove" Width="90px"></asp:TextBox></td>
<td style="width: 3px"><asp:ImageButton ID="imgEndDate"
runat="server" ImageUrl="~/images/Calendar_scheduleHS.bmp"
ValidationGroup="txtEndDate" /></td>
<td style="width: 3px">
</td>
</tr>
<tr>
<td style="width: 3px">
<asp:Label ID="Label1" runat="server"
ForeColor="White" Text="-" Width="80px"></asp:Label></td>
<td style="width: 3px">
</td>
<td style="width: 3px">
</td>
<td style="width: 3px">
</td>
<td style="width: 3px">
</td>
<td style="width: 3px">
</td>
<td style="width: 3px">
</td>
<td style="width: 3px">
</td>
</tr>
<tr>
<td colspan="2">
<asp
ropDownList ID="ddlReports" runat="server"
Width="181px" AutoPostBack="True">
</asp
ropDownList></td>
<td colspan="3">
<asp:Button ID="btnGetData" runat="server"
OnClick="btnGetData_Click" Text="Generate Report" Width="123px" /></
td>
<td colspan="3">
<asp:Button ID="btnExport" runat="server"
OnClick="btnExport_Click" Text="Export To Excel" Width="116px" /></td>
</tr>
<tr><td colspan="8" align="center">
<asp:Label ID="LblAgencies" runat="server"
Text="Agencies" ForeColor="Black" Visible="False"></asp:Label>
<asp
ropDownList ID="DropDownListAgencies" runat="server"
Visible="False">
</asp
ropDownList><br />
</td></tr>
<tr>
<td colspan="8">
<asp:Label ID="Label2" runat="server"
ForeColor="White" Text="__"></asp:Label></td>
</tr>
<tr>
<td colspan="8">
</td>
</tr>
</table>
asdfsdafasdfasd<asp:SqlDataSource
ID="SqlDataSourceDailyOutreachReport" runat="server"
ConnectionString="<%$
ConnectionStrings
BDHSCentralConnectionString %>"
SelectCommand="DailyOutreachReport"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:SessionParameter Name="StartDate"
SessionField="DOStartDate" Type="DateTime" />
<asp:SessionParameter Name="endDate"
SessionField="DOEndDate" Type="DateTime" />
<asp:SessionParameter Name="AgencyName"
SessionField="DOAgencyName" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridViewDailyOutreachReport2" runat="server"
AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID"
DataSourceID="SqlDataSourceDailyOutreachReport">
<asp:BoundField DataField="ID" HeaderText="ID"
InsertVisible="False" ReadOnly="True"
SortExpression="ID" Visible="False" />
<asp:BoundField DataField="Date Reported" HeaderText="Date
Reported" SortExpression="Date Reported" />
<asp:BoundField DataField="Date Submitted" HeaderText="Date
Submitted" SortExpression="Date Submitted" />
<asp:BoundField DataField="Agency Name" HeaderText="Agency
Name" SortExpression="Agency Name" />
</Columns>
</asp:GridView>
<br />
THANKS