Click here to Skip to main content
15,893,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey All ,
I wish you could find solution for my problem
i want to use binding expression in SQL SelectCommand

XML
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
                        ConnectionString="<%$ ConnectionStrings:OpticsConnectionString %>"
                        SelectCommand="SELECT [pro_name], [pro_purchased_qty], [pro_sale_price], [Purchases_price]
                        FROM
                        [rpt_UVU_allOrders_In_Details_R]
                        WHERE
                        [order_id]"+'<%#"="+Eval("order_id") %>'>
                    </asp:SqlDataSource>



but it always gives me that error
The server tag is not well formed.

Please help me :)

Best Regards ,
Ahmed Mandour
Posted

<%# Eval("order_id") %> is more than enough I guess. Remove the "=" from the expression.
 
Share this answer
 
Use SelectParameter

XML
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
       ConnectionString="<%$ ConnectionStrings:OpticsConnectionString %>"
       SelectCommand="SELECT [pro_name],
       [pro_purchased_qty], [pro_sale_price], [Purchases_price]
       FROM [rpt_UVU_allOrders_In_Details_R] WHERE ([order_id] = @order_id)">
       <SelectParameters>
            <asp:Parameter Name="order_id" />
       </SelectParameters>
</asp:SqlDataSource>

You can apply parameter value from code behind.
<code>
SqlDataSource3.SelectParameters["order_id"].DefaultValue = "value";
</code>

Beside SelectParameter offers few built-in parameter types.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900