sqldatasource select命令中的语法

发布于 2024-08-28 03:57:26 字数 523 浏览 7 评论 0 原文

我的 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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

那支青花 2024-09-04 03:57:27

您好,我以这种方式解决了这个问题(按照如何使用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

堇年纸鸢 2024-09-04 03:57:26

这可能是一个更普遍的问题“

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

It could be a more general issue with "

 <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
         ConnectionString="<%$ConnectionStrings:conn %>" 
         SelectCommand='<%# Eval("TypeID", "SELECT ItemID, ItemType, ItemType + "\" \"" + ItemDescription As ItemInfo WHERE ItemType = {0}")%>'> 
 </asp:SqlDataSource>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文