Reputation: 199
I have a web form having a grid bonded to SQL data source. But the select command of the SQL data source is dynamically accepted and stored in a static class which resides in app_code file of my project. How do I set the select command of the SQL data source to this query in the app_code class?
I did something like this :
<script type="text/C#" runat="server" language="c#" src="ReportGenerationGrid.aspx.cs">
SqlDataSource1.SelectCommand = ParametersRetainer.Query;
</script>
But its not working.
Upvotes: 1
Views: 191
Reputation: 1039200
You could use the code behind:
protected void Page_Load(object sender, EventArgs e)
{
SqlDataSource1.SelectCommand = ParametersRetainer.Query;
}
or if you don't use a code behind file then you could do it inline:
<script type="text/C#" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
SqlDataSource1.SelectCommand = ParametersRetainer.Query;
}
</script>
Upvotes: 1