我的SqlDataSource select命令由Eval单向数据绑定语法的String.Format功能动态更改。它工作正常。但是我需要将两个列值放在一起,中间有一个空格(ItemType +'“”'+ ItemDescription As ItemInfo)但是我收到消息时无法正确获取语法:“服务器标签格式不正确“
你能帮忙吗?非常感谢 <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 :(得分:0)
“
可能是一个更普遍的问题 <asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ConnectionStrings:conn %>"
SelectCommand='<%# Eval("TypeID", "SELECT ItemID, ItemType, ItemType + "\" \"" + ItemDescription As ItemInfo WHERE ItemType = {0}")%>'>
</asp:SqlDataSource>
答案 1 :(得分: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>
非常感谢