My SqlDataSource selectcommand is dynamically changed by the String.Format functionality of the Eval one-way databinding syntax. It works ok. However I need to put together two colu开发者_如何学编程mns values with a space in the middle (ItemType + '" "' + ItemDescription As ItemInfo) but I can't get the syntax correct as I get the message: "The server tag is not well formed"
Can you help? Many thanks
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:conn %>" SelectCommand='<%# Eval("TypeID", "SELECT ItemID, ItemType, ItemType + '" "' + ItemDescription As ItemInfo WHERE ItemType = {0}")%>'>
</asp:SqlDataSource>
It could be a more general issue with "
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ConnectionStrings:conn %>"
SelectCommand='<%# Eval("TypeID", "SELECT ItemID, ItemType, ItemType + "\" \"" + ItemDescription As ItemInfo WHERE ItemType = {0}")%>'>
</asp:SqlDataSource>
HiI resolved the issue in this way (as advised in How to use Single Quotes in Eval Format String )
In items.aspx.vb
Protected Const SqlQuery As String = "SELECT ItemID, ItemType, ItemType + " + "' '" + " ItemDescription As ItemInfo WHERE ItemType = {0}"
In items.aspx
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:conn %>" SelectCommand='<%# Eval("TypeID", SQLQuery)%>'> </asp:SqlDataSource>
Many thanks
精彩评论