javierpdx
asked on
Moving a select statement from aspx file to .cs file
Hello,
I'm using c#, .net for my application and connecting to SQL 2012.
I'm having a hard time finding information on how to move this SQLDataSource select statement to the code code behind C# file and referencing it in my aspx page.
This is the reference in my aspx file. How do I move the select statement to my .cs file?
I'm using c#, .net for my application and connecting to SQL 2012.
I'm having a hard time finding information on how to move this SQLDataSource select statement to the code code behind C# file and referencing it in my aspx page.
This is the reference in my aspx file. How do I move the select statement to my .cs file?
<asp:SqlDataSource ID="SqlDS" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
SelectCommand="SELECT S.IsActive, S.Title, S.AllowTransfer, S.GuestFee
FROM Sessions S WHERE (IsActive = 'True') AND (AllowTransfer = 'True')">
</asp:SqlDataSource>
Thanks for looking at this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Got it. Thanks. It's working now without the commandtext.
I appreciate the help.
I appreciate the help.
ASKER
I'm trying this in the CS file but am getting this error:
Error 16 'string' does not contain a definition for 'CommandText' and no extension method 'CommandText' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)