2010-04-07 50 views
0

我的SqlDataSource selectcommand由Eval单向数据绑定语法的String.Format功能动态更改。它工作正常。不过,我需要将两个列值放在一起(ItemType +'“”'+ ItemDescription As ItemInfo),但我无法得到正确的语法,因为我得到的消息是:“服务器标记形式不正确“语法在sqldatasource selectcommand

你能帮忙吗?非常感谢

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:conn %>" SelectCommand='<%# Eval("TypeID", "SELECT ItemID, ItemType, ItemType + '" "' + ItemDescription As ItemInfo WHERE ItemType = {0}")%>'> </asp:SqlDataSource>

回答

0

这可能是与“

<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> 
+0

遗憾,这是行不通的 – netNewbi3 2010-04-07 13:19:02

+0

那么它不是“”的问题,它是一个“ – Nix 2010-04-07 15:59:12

+0

千恩万谢,但不工作 – netNewbi3 2010-04-08 09:06:51

0

HII解决这样的问题(如建议在How to use Single Quotes in Eval Format String

在items.aspx.vb一个更普遍的问题

Protected Const SqlQuery As String = "SELECT ItemID, ItemType, ItemType + " + "' '" + " ItemDescription As ItemInfo WHERE ItemType = {0}"

在items.aspx

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:conn %>" SelectCommand='<%# Eval("TypeID", SQLQuery)%>'> </asp:SqlDataSource>

非常感谢

相关问题