如何隐藏在ASP.NET表单列 [英] how to hide columns in ASP.NET webform
问题描述
在我PrinterPackage ASPX 的文件我有以下的用户控制:
In my PrinterPackage.aspx file i have the following 'User Control':
<%@ Register Src="~/ProvisionControls/DeferredTaxRollforwardControl.ascx" TagPrefix="uc9" TagName="DeferredTaxesRollforwardControl" %>
...
...
<div>
<uc9:DeferredTaxesRollforwardControl ID="DeferredTaxesRollforwardControl1" runat="server" />
</div>
它调用控制文件DeferredTaxRollforwardControl ASCX 。'包含如下定义我的表:
which calls the control file 'DeferredTaxRollforwardControl.ascx' that contains my table defined as follows:
<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>
我试图显示表,也隐藏着一些使用以下code在我PrinterPackage列 aspx.cs 文件:
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;
但是,这似乎并没有拿起表行 tblTempDiff ,并给了我一个空值来代替。我怎样才能导入数据来自的TableRow tblTempDiff 到行,然后隐藏我想隐藏什么列?
But, this doesn't seem to pick up the table row tblTempDiff and gives me a null value instead. How can i import the data from the TableRow tblTempDiff into row and then hide whatever columns i want to hide?
请向我提问,如果你需要更多的信息,因为我知道,当谈到解释我的问题我不是最好的人。
推荐答案
在code背后看不到的&LT; TR&GT;
创建,因为它不是一个服务器控制。在 =服务器
属性添加到&LT; TR&GT;
:
The code behind cannot see the <tr>
you created because it's not a server control. Add the runat="server"
attribute to the <tr>
:
<tr id="tblTempDiff" runat="server">
和使用<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltablerow%28v=vs.110%29.aspx\"相对=> System.Web.UI.HtmlControls.HtmlTableRow
的nofollow的,而不是的TableRow
。两个不同的东西。
And use System.Web.UI.HtmlControls.HtmlTableRow
instead of TableRow
. Two different things.
这篇关于如何隐藏在ASP.NET表单列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!