我的 SqlDataSource select 命令由 Eval 单向数据绑定语法的 String.Format 功能动态更改。工作正常。但是,我需要将两列值放在一起,中间有一个空格(ItemType + '" "' + ItemDescription As ItemInfo),但当我收到消息时,我无法获得正确的语法:“服务器标记格式不正确“
你能帮忙吗?非常感谢
'>;
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>
发布评论
评论(2)
您好,我以这种方式解决了这个问题(按照如何使用Eval 格式字符串中的单引号 )
在 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)%>'>;
非常感谢
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
这可能是一个更普遍的问题“
It could be a more general issue with "