如何在ASP.NET控件声明中的属性中添加换行符? [英] How do I add linebreaks to a property in an ASP.NET control declaration?

查看:92
本文介绍了如何在ASP.NET控件声明中的属性中添加换行符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个sql数据源,并且我有一个很长的SQL字符串.我想在SQL中插入换行符,但Visual Studio似乎不喜欢换行符.我该如何插入换行符?

I have a sql data source and I have a really long string of SQL. I want to put linebreaks in my sql but Visual Studio doesn't seem to like the linebreaks. How would I put in line breaks?

示例

<asp:SqlDataSource ID="SqlDataSource1" runat="server"         
        ProviderName="System.Data.SqlClient" 
        SelectCommand="select aci.ACIOI, aci.AccountNum, (select count(r.OI) from Report r where aci.ACIOI = r.ACIOI) as ReportCount, ci.Name, aci.BusinessName, ci.[Address] As StreetAddress, ci.Town, ci.Zip, ci.Phone  from AdditionalCustomerInformation aci  left join CustomerInformation ci on ci.ACI_OI = aci.ACIOI where (select count(r.OI) from Report r where aci.ACIOI = r.ACIOI) >= 1" 
        >        
        </asp:SqlDataSource>

推荐答案

这对我来说编译得很好:

This compiles just fine for me:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ProviderName="System.Data.SqlClient" SelectCommand="select aci.ACIOI, 
aci.AccountNum, (select count(r.OI) from Report r where aci.ACIOI = r.ACIOI) as ReportCount,
ci.Name, aci.BusinessName, 
ci.[Address] As StreetAddress, ci.Town, 
ci.Zip, ci.Phone 
from AdditionalCustomerInformation aci left join CustomerInformation ci on ci.ACI_OI = aci.ACIOI 
where (select count(r.OI) from Report r where aci.ACIOI = r.ACIOI) >=1"> </asp:SqlDataSource>

...这是合乎逻辑的.只要整个SQL语句包含在 SelectCommand 属性的引号中,编译器就不会在乎您的标记是否分成几行.

... which is logical. The compiler should not care if your markup is broken up into separate lines as long as the entire SQL statement is enclosed in quotes of the SelectCommand property.

出现的问题是由于SQL语句中的> 符号.有两种方法可以转义该符号.您可以简单地使用& gt; HTML实体,如下所示:

The problem it appears is because of the > symbol in your SQL statement. There are two ways to escape that symbol. You could simply use the &gt; HTML entity instead, as follows:

SelectCommand = "SELECT.... &gt;= 1"

这篇关于如何在ASP.NET控件声明中的属性中添加换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆