...

View Full Version : Passing variables from one page to another



dougancil
04-22-2011, 04:26 PM
I have two web pages that I'm passing variables that are needed for 2 sql stored procedures to fill a datatable. The user will see their results on page one, click on a link and be taken to page 2, which passes the variables in the URL. I can see that the variables are being passed to the second page, but my stored procedure isn't firing. Here is my code for the datatable on the first page:



<asp:GridView ID="GridView1" runat="server" HorizontalAlign="Center"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="SchedName" HeaderText="SchedName"
SortExpression="SchedName" />
<asp:BoundField DataField="ActivityDate" HeaderText="ActivityDate"
ReadOnly="True" SortExpression="ActivityDate" />
<asp:BoundField DataField="By" HeaderText="By" SortExpression="By" />
<asp:BoundField DataField="Activity" HeaderText="Activity" ReadOnly="True"
SortExpression="Activity" />
<asp:BoundField DataField="FirstListing" HeaderText="FirstListing"
SortExpression="FirstListing" />
<asp:TemplateField HeaderText="OncallStart" SortExpression="OnCallStart">
<ItemTemplate>
<asp:HyperLink ID="OnCallStart" runat="server" Text='<%# Eval("OncallStart") %>'
NavigateUrl='<%# String.Format("\website1\Default2.aspx?schedname={0}&date={1}", Eval("schedname"), Eval("OncallStart")) %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="OnCallEnd" HeaderText="OnCallEnd" ReadOnly="True"
SortExpression="OnCallEnd" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:MDRConnectionString %>"
SelectCommand="sp_getoncallresults" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="sincedateTextBox" DbType="DateTime"
Name="sincedate" PropertyName="Text" />
<asp:ControlParameter ControlID="schednameTextBox" Name="schedname"
PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

and here is the URL when a user clicks on the link in the datagridview:

http://10.2.1.66/website1/Default2.aspx?schedname=CTKA&date=4/21/2011%205:00:00%20PM

and here is the code for the datagridview on page 2:

<asp:GridView ID="GridView1" runat="server" style="text-align: center"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="SchedName" HeaderText="SchedName"
SortExpression="SchedName" />
<asp:HyperLinkField DataTextField="ActivityDate" HeaderText="ActivityDate"
NavigateUrl="\website1\default.aspx" SortExpression="ActivityDate" />
<asp:BoundField DataField="By" HeaderText="By" SortExpression="By" />
<asp:BoundField DataField="Activity" HeaderText="Activity" ReadOnly="True"
SortExpression="Activity" />
<asp:BoundField DataField="FirstListing" HeaderText="FirstListing"
SortExpression="FirstListing" />
</Columns>
</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:MDRConnectionString %>"
ProviderName="System.Data.SqlClient" SelectCommand="sp_getoncallresults3"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter DbType="DateTime" Name="date"
QueryStringField="date" />
<asp:QueryStringParameter DbType="String" Name="schedname"
QueryStringField="schedname" />
<asp:Parameter Direction="ReturnValue" Name="RETURN_VALUE" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>


And on the form load event of page 2 I have this line of code:


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Convert.ToDateTime(Request.QueryString("date")).ToShortDateString()
End Sub


I have verified all of my variable names and types against my database and I'm not seeing any results. What am I missing?

Thank you

Doug



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum