我正在尝试使用GridView并从单击的行中获取数据.我已经尝试了下面的代码,当我单击该行时,我返回所选索引,但当我查看GridView中的实际行时,它们显示为空.不确定我错过了什么.
.ASP制作我的网格.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="True"
CssClass="datatables" Width="100%"
DataSourceID="SqlDataSource1"
GridLines="None" ShowFooter="True" AllowSorting="True"
onrowcreated="GridView1_RowCreated"
onrowdatabound="GridView1_RowDataBound" ShowHeaderWhenEmpty="True"
onrowcommand="GridView1_RowCommand"
onselectedindexchanged="GridView1_SelectedIndexChanged">
<HeaderStyle CssClass="hdrow" />
<RowStyle CssClass="datarow" />
<PagerStyle CssClass="cssPager" />
</asp:GridView>
Run Code Online (Sandbox Code Playgroud)
在每行数据绑定上,我确保单击应设置所选索引.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(GridView1, "Select$" + e.Row.RowIndex);
}
}
Run Code Online (Sandbox Code Playgroud)
然后,当所选索引通过单击此更改被触发时,我可以在第一行放置断点,并且我看到我点击的索引存储在a中.然而,当我到达foreach时,它会跳过它,因为它显示GridView1的Count为0行.理论上它应该有几百行,当索引匹配时,它应该抓取第6个单元格中的数据并将其存储在字符串b中.为什么我的点击没有行?
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
int a = GridView1.SelectedIndex
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowIndex == a)
{
b = row.Cells[6].Text;
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的页面加载.
protected void …
Run Code Online (Sandbox Code Playgroud) 我正在研究一些先前在我公司开发的开发人员试图将一个代码添加ReportViewer
到ASP.NET C#页面.当我开始调试时,我得到以下内容.
Parser Error Message: The base class includes the field 'ReportViewer1', but its type
(Microsoft.Reporting.WebForms.ReportViewer) is not compatible with the type of control
(Microsoft.Reporting.WebForms.ReportViewer).
Run Code Online (Sandbox Code Playgroud)
我读了一些文章,建议我的参考可能是旧的.我在引用Microsoft.ReportViewer.WebForms 9.0.0.0.
我有一个ReportViewer
不同的页面,同一个项目,正在运作.当我改变WebForms 10.0.0.0
对它的引用时,会打破类似的消息.为了让它再次工作,我必须改变回来9.0.0.0
并web.config
在我做出这个改变之前把它放回去.
要使所有ReportViewers工作,我需要在9.0.0.0或10.0.0.0上,我是否需要更改web.config?
以下是两位报告查看者.我没有看到任何与他们不同的相关内容.
今天在page1.aspx的9.0.0.0下工作
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Height="515px" ProcessingMode="Remote" Width="100%" Visible="false">
<ServerReport ReportServerUrl="http://servername/reportserver" />
</rsweb:ReportViewer>
Run Code Online (Sandbox Code Playgroud)
在page2.aspx中不在9.0.0.0或10.0.0.0下工作
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
Font-Size="8pt" ProcessingMode="Remote"
WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
<ServerReport ReportServerUrl="http://servername/reportserver" />
</rsweb:ReportViewer>
Run Code Online (Sandbox Code Playgroud) 我有一个在c#中定义的字符串数组
string[,] options = new string[100,3];
Run Code Online (Sandbox Code Playgroud)
在整个代码中,它会填充数据,但并不总是填充.
因此,如果我有80个部分填充它,20个部分没有填充.20个部分中包含空值或最后有60个空值.是否有一种简单的方法来调整数组的大小,以便在填充数组后,数组与之相同
String[,] options = new string[80,3];
Run Code Online (Sandbox Code Playgroud)
它必须根据它找到的第一组3个零点的位置来调整大小.
如果这是一个锯齿状的阵列,我会做的
options = options.Where(x => x != null).ToArray();
Run Code Online (Sandbox Code Playgroud) 我在 .asp.net 中有一个名为 chrt 的饼图。我希望在图表中以货币格式显示值而不是标签。我希望标签显示在图例中。我执行以下操作并在图表上显示值而不是标签,并且标签仍然显示在图例中。
chrt.Series[0].IsValueShownAsLabel = true;
Run Code Online (Sandbox Code Playgroud)
例子:
图表显示“12345.678”图例显示“销售”
我现在需要的只是让图表以美元显示。
如果我执行以下操作,它会将图表上的格式更改为货币,但不幸的是,会将图例中的标签替换为货币格式的值。
foreach (Series b in chrt.Series)
{
foreach (DataPoint c in b.Points)
{
//Sets both legend and chart value
c.Label = c.YValues[0].ToString("C");
}
}
Run Code Online (Sandbox Code Playgroud)
例子:
图表显示“$12345.68”图例显示“$12345.68”
我还尝试了下面的代码,但它将图例设置为值并将其格式化为货币,使图表上的值保持原样。
foreach (Series b in chrt.Series)
{
foreach (DataPoint c in b.Points)
{
//Sets just the legend to the dollar values
c.AxisLabel = c.YValues[0].ToString("C");
}
}
Run Code Online (Sandbox Code Playgroud)
例子:
图表显示“12345.678”图例显示“$12345.68”
我想要它展示的是
图表显示“$12345.68”图例显示“销售额”
我正在尝试使用 c# 删除远程服务器上的用户配置文件。我正在以自己的身份运行该程序。如果我以自己的身份浏览到 \\server\c$\Users\,我可以删除目录“User”。它没有错误。如果我使用我用 C# 编写的程序和下面的代码来尝试删除同一个目录,我会得到这个异常。
拒绝访问路径“appsFolder.itemdata-ms”。
我的删除有什么问题吗?
Directory.Delete("\\\\server\\c$\\Users\\User\\",true);
Run Code Online (Sandbox Code Playgroud) c# ×5
asp.net ×3
arrays ×1
aspchart ×1
gridview ×1
gridviewrow ×1
onclick ×1
reportviewer ×1
string ×1
user-profile ×1
web-config ×1