C# 如何在ASP.NET Web窗体中隐藏列
在PrinterPackage.aspx文件中,我有以下“用户控件”: 但是,这似乎没有拾取表行tblTempDiff,而是给了我一个空值。如何将数据从TableRow tblTempDiff导入row,然后隐藏我想要隐藏的任何列C# 如何在ASP.NET Web窗体中隐藏列,c#,asp.net,C#,Asp.net,在PrinterPackage.aspx文件中,我有以下“用户控件”: 但是,这似乎没有拾取表行tblTempDiff,而是给了我一个空值。如何将数据从TableRow tblTempDiff导入row,然后隐藏我想要隐藏的任何列 如果您需要更多信息,请向我提问,因为我知道我不是解释问题的最佳人选。@user1319424:与其已经创建表,不如使用placeholder,然后创建动态表并将该表绑定到占位符 请参阅以下链接: 隐藏的代码无法看到您创建的,因为它不是服务器控件。将runat=serv
如果您需要更多信息,请向我提问,因为我知道我不是解释问题的最佳人选。@user1319424:与其已经创建表,不如使用placeholder,然后创建动态表并将该表绑定到占位符 请参阅以下链接:
隐藏的代码无法看到您创建的,因为它不是服务器控件。将runat=server属性添加到:
并使用而不是TableRow。两件不同的事情。即使包含runat=server,它仍然无法填充我的TableRow“row”。还有其他方法可以实现同样的事情吗?你能给我举个例子吗?还是空的吗?或者单元格是空的?当我调试它时,它仍然显示null作为“row”的值。当它试图执行visible=false时,它会给我一个null异常。既然我试图隐藏此列,我可以以任何方式使用“Label ID=lblgrandtotalunadjustedbegingbalance”吗?请检查我的编辑。使用System.Web.UI.HtmlControl.HtmlTableRow而不是TableRow,然后看看情况如何。我无法更改现有表或创建新的动态表,因为我正在将功能添加到现有代码中,不想重新创建现有的功能。我还有别的办法可以做到吗?
<%@ Register Src="~/ProvisionControls/DeferredTaxRollforwardControl.ascx" TagPrefix="uc9" TagName="DeferredTaxesRollforwardControl" %>
...
...
<div>
<uc9:DeferredTaxesRollforwardControl ID="DeferredTaxesRollforwardControl1" runat="server" />
</div>
<table style="width: 4600px; border-spacing:0px;" border="0" frame="hsides" cellpadding="2" cellspacing="1">
<tr id = "tblTempDiff"> //want to import this
<td style="width:7.6%;" width="2px;" class="paintYellowTotalLeftBold">
Grand Total Current
</td>
<td style="width:2.8%;" width="2px;" class="paintYellowTotalBold">
<asp:Label ID="lblGrandTotalUnadjustedBeginningBalance" runat="server" Text=""></asp:Label>
</td>
... and more <td>
TableRow row = DeferredTaxesRollforwardControl1.FindControl("tblTempDiff") as TableRow;
row.Cells[0].Visible = true;
row.Cells[1].Visible = true;
row.Cells[2].Visible = true;
row.Cells[3].Visible = true;
row.Cells[4].Visible = true;
row.Cells[5].Visible = true;
row.Cells[6].Visible = true;
row.Cells[7].Visible = true;
row.Cells[8].Visible = true;
row.Cells[9].Visible = false;
row.Cells[10].Visible = false;
row.Cells[11].Visible = false;
row.Cells[12].Visible = false;
<tr id="tblTempDiff" runat="server">