views:

150

answers:

2

Hi,

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>

A: 

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>
Nix
sorry, it doesn't work
netNewbi3
then its not a " " issue, its a "
Nix
many thanks, but not working
netNewbi3
A: 

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

netNewbi3