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 columns 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>

link|improve this question
feedback

2 Answers

It could be a more general issue with "

 <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
         ConnectionString="<%$ConnectionStrings:conn %>" 
         SelectCommand='<%# Eval(&quot;TypeID&quot;, &quot;SELECT ItemID, ItemType, ItemType + &quot;\" \"&quot; + ItemDescription As ItemInfo WHERE ItemType = {0}&quot;)%>'> 
 </asp:SqlDataSource>
link|improve this answer
sorry, it doesn't work – netNewbi3 Apr 7 '10 at 13:19
then its not a " " issue, its a " – Nix Apr 7 '10 at 15:59
many thanks, but not working – netNewbi3 Apr 8 '10 at 9:06
feedback

HiI resolved the issue in this way (as advised in http://stackoverflow.com/questions/264414/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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.