I want to create a dynamic select command in an SQLDataSource. It should read a value from the URL sent using get, grab it and stick it into the select command.
My sqldatadource is in my aspx page and looks like this
<asp:SqlDataSource ID="DS" Runat="server"
SelectCommand="SELECT * FROM [dbo].[DS] WHERE [Install Process] = 'OCC'
AND [The Date] = @theDate"
ConnectionString="<%$ ConnectionStrings:ApplicationServices %>">
</asp:SqlDataSource>
I want to update theDate parameter. I'm guessing you cant update it in Page_Load because the page hasn't loaded yet but I'm honestly not sure. can i call a codebehind function from within the sqldatasource or something...
This is my codebehind. It's currently in the page_load method, but i'm guessing that I need to move it? any help would be great. Thanks
protected void Page_Load(object sender, EventArgs e)
{
string theDate = Request.QueryString["TheDate"];
DS.SelectParameters.Add("@theDate", theDate);
DS.SelectParameters["theDate"].DefaultValue = theDate.ToString();
}