簡體   English   中英

sqldatasource selectcommand中的語法

[英]syntax in sqldatasource selectcommand

我的SqlDataSource selectcommand由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>

可能是“

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

HiI以這種方式解決了該問題(如如何在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)%>'> </asp:SqlDataSource>

非常感謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM