I have a web page calling another web page and I want to build a MySQL query in the calling page and pass it to the SelectCommand on the called page to show the results in a GridView control.
Server.Transfer("~/Experiments/Default.aspx", True) // opens the new page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Session("query") = Request.Form("strSql") // this is Page_load of the called page; strSql was the query built on the calling page
End Sub
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand = "?" >
<SelectParameters>
<asp:SessionParameter
Name="query"
SessionField="?"
DefaultValue = "SELECT * FROM experiment" /> // if I omit DefaultValue I get an empty page; if I include DefaultValue I get a SQL error
</SelectParameters>
</asp:SqlDataSource>
Any ideas?