当@RadioServiceGroup设置为NULL时,我想返回sbi_l_radioservicecodes表中包含大约120条记录的所有记录.但是,当我执行以下过程并将@RadioServiceGroup设置为NULL时,它不返回任何记录.这是存储过程:
CREATE PROCEDURE [dbo].[GetRadioServiceCodes]
@RadioServiceGroup nvarchar(1000) = NULL
AS
BEGIN
IF(@RadioServiceGroup = NULL)
BEGIN
SELECT rsc.RadioService
FROM sbi_l_radioservicecodes rsc
END
ELSE
BEGIN
SELECT rsc.RadioService
FROM sbi_l_radioservicecodes rsc
WHERE rsc.RadioServiceGroup = @RadioServiceGroup
END
END
Run Code Online (Sandbox Code Playgroud) 我有一个绑定到GridView的DataTable.我还有一个按钮,单击时将DataTable导出到Excel文件.但是,发生以下错误:
ErrMsg ="线程正在中止."
以下是抛出错误的代码的一部分:
private static void Export_with_XSLT_Web(DataSet dsExport,
string[] sHeaders,
string[] sFileds,
ExportFormat FormatType,
string FileName)
{
try
{
// Appending Headers
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
if(FormatType == ExportFormat.CSV)
{
HttpContext.Current.Response.ContentType = "text/csv";
HttpContext.Current.Response.AppendHeader("content-disposition",
"attachment;
filename=" + FileName);
}
else
{
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
HttpContext.Current.Response.AppendHeader("content-disposition",
"attachment;
filename=" + FileName);
}
// XSLT to use for transforming this dataset.
MemoryStream stream = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8);
CreateStylesheet(writer, sHeaders, sFileds, FormatType);
writer.Flush();
stream.Seek(0, SeekOrigin.Begin);
XmlDataDocument xmlDoc = …Run Code Online (Sandbox Code Playgroud) 我有一个简单的Web表单,其中包含几个列表框和一个搜索按钮.单击该按钮时,它将返回一个DataSet.如果数据集包含记录,我将最初设置为false的asp:标签设置为true,但这不会发生.如果数据集包含记录且visible属性设置为true,则标签仍未显示.
我还尝试将标签和其他一些控件放在html表中,并在表上设置runat ="server"属性并更改其可见性,但它也没有显示.
这是aspx代码:
<table>
<tr>
<td>
<asp:Label ID="lblSortBy" runat="server" Text="Sort By:" Visible="false">
</asp:Label>
<asp:DropDownList
ID="ddlSortBy"
runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="ddlSortBy_SelectedIndexChanged">
<asp:ListItem Value="Gross">Gross</asp:ListItem>
<asp:ListItem Value="Population">Population</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
这是单击按钮时的简化代码:
public void GetData()
{
DataView dv = GetReportData().DefaultView;
if(dv.ToTable().Rows.Count > 0)
{
lblSortBy.Visible = true;
}
else
{
lblSortBy.Visible = false;
}
}
Run Code Online (Sandbox Code Playgroud)
我在一些ListBoxes和GridView周围有几个更新面板,但没有标签和下拉列表.这会引起问题吗?
我做了一个测试,如果找到记录并且标签消失,我将更新面板中的标签设置为false,因此如果它在更新面板中,它就可以正常工作.
是否有规则规定所有链接都应加下划线以使它们看起来像链接?我看过很多站点,例如,页脚没有下划线链接.
我有以下存储过程返回A,B和降序计数.我试图用ROW_NUMBER,这样我就可以页的记录,但我希望第一个行号1是具有最高计数的记录,所以基本上,如果我返回一个表3次的记录和计数30,20,10,再行号1应计对应30,行号2应与计数对应20,和行号3应与计数对应10. dbo.f_GetCount是一个返回计数的函数.
create procedure dbo.Test
as
@A nvarchar(300) = NULL,
@B nvarchar(10) = NULL
as
select @A = nullif(@A,'')
,@B = nullif(@B,'');
select h.A
,hrl.B
,dbo.f_GetCount(hrl.A,h.B) as cnt
from dbo.hrl
inner join dbo.h
on h.C = hrl.C
where(@A is null
or h.A like '%'+@A+'%'
)
and (@B is null
or hrl.B = @B …Run Code Online (Sandbox Code Playgroud) 当我分配AssociatedUpdatePanelId时,我选择状态时不会显示进度,但是当我将其留空时,它会显示进度.
这是aspx标记:
<div>
<asp:ListBox ID="lstStates" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="lstStates_SelectedIndexChanged" SelectionMode="Multiple">
</asp:ListBox>
</div>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlCounty" runat="server">
<asp:ListBox ID="lstCounties" runat="server" SelectionMode="Multiple">
</asp:ListBox>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lstStates" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress2" runat="server" DisplayAfter="1"
AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<img src="../images/loader2.gif" />
Loading Counties...
</ProgressTemplate>
</asp:UpdateProgress>
</div>
Run Code Online (Sandbox Code Playgroud) 我在这里看到一个关于承认你写过的最糟糕的代码的问题,我不太确定,因为我不知道为什么这是错误的代码.
public string GetUsername (string userName)
{
User user = DbLookup.GetUser(userName);
return user.Username;
}
Run Code Online (Sandbox Code Playgroud)
是因为它假定username存在并且不检查null?或者还有更多吗?
什么数据类型最好存储html内容和文档,如pdf,excel文件和word文档.我目前正在使用ntext,但我不确定这是否是存储html内容的最佳数据类型.
此外,我目前使用FCKEditor将html内容保存到ntext字段,并将标记与样式一起存储.如果我碰巧将描述的一部分读入ListView的ItemTemplate,其中包含以下内容:
<%# Eval("content") %>
Run Code Online (Sandbox Code Playgroud)
它显示内容,但也显示标记.例如,而不是显示:
"This is an html string",它会显示 <p>This is and html <b>string</b></p>
我有4个文本框,只能取一个数字.问题是我必须为控件创建4个单独的验证器,并将它们的id与验证器相关联.是否可以只有一个asp.net正则表达式验证器并将所有控件与该验证器相关联?
例如,当使用REST请求对象时,是否可以以json和xml格式获取响应,或者我是否必须创建类似于以下内容的UriTemplates:
[WebInvoke(UriTemplate="&format=json?user/{id}", ResponseFormat=WebMessageFormat.Json)]
[WebInvoke(UriTemplate="&format=xml?user/{id}", ResponseFormat=WebMessageFormat.Xml)]
Run Code Online (Sandbox Code Playgroud)
我问的原因是因为我可能需要为Android手机上的应用程序返回一种格式,并为笔记本电脑上的应用程序返回另一种类型.
此外,方法可以具有相同的名称,如注册或我必须有一个名称:
RegisterJSON(用户用户)和另一个名为RegisterXML(用户用户)
asp.net ×5
c# ×5
t-sql ×3
html ×2
sql-server ×2
.net ×1
exception ×1
sql ×1
updatepanel ×1
wcf ×1