[英]how to hide columns in ASP.NET webform
In my PrinterPackage. 在我的PrinterPackage中。
aspx file i have the following
'User Control' :
我的aspx文件具有以下
“用户控制” :
<%@ Register Src="~/ProvisionControls/DeferredTaxRollforwardControl.ascx" TagPrefix="uc9" TagName="DeferredTaxesRollforwardControl" %>
...
...
<div>
<uc9:DeferredTaxesRollforwardControl ID="DeferredTaxesRollforwardControl1" runat="server" />
</div>
which calls the control file 'DeferredTaxRollforwardControl. 它将调用控制文件'DeferredTaxRollforwardControl。
ascx ' that contains my table defined as follows:
包含我的表的ascx '定义如下:
<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>
I am trying to display the table and also hide some of the columns using the following code in my PrinterPackage. 我正在尝试显示表,并在我的PrinterPackage中使用以下代码隐藏一些列。
aspx.cs file :
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;
But, this doesn't seem to pick up the table row tblTempDiff and gives me a null value instead.
但是,这似乎并没有占用表行tblTempDiff ,而是给了我一个空值。 How can i import the data from the TableRow
tblTempDiff into
row and then hide whatever columns i want to hide?
如何将TableRow tblTempDiff中的数据导入
行 ,然后隐藏我要隐藏的任何列?
Please ask me questions if you need more information, as i know i am not the best person when it comes to explaining my questions.
如果您需要更多信息,请问我问题,因为我知道在解释我的问题时我不是最好的人。
@user1319424: Rather than already creating table, use place holder and then create dynamic table and bind that table to a placeholder. @ user1319424:使用占位符,然后创建动态表并将该表绑定到占位符,而不是先创建表。
Refer below link: http://www.dotnetcurry.com/ShowArticle.aspx?ID=135 请参阅下面的链接: http : //www.dotnetcurry.com/ShowArticle.aspx?ID=135
The code behind cannot see the <tr>
you created because it's not a server control. 后面的代码看不到您创建的
<tr>
,因为它不是服务器控件。 Add the runat="server"
attribute to the <tr>
: 将
runat="server"
属性添加到<tr>
:
<tr id="tblTempDiff" runat="server">
And use System.Web.UI.HtmlControls.HtmlTableRow
instead of TableRow
. 并使用
System.Web.UI.HtmlControls.HtmlTableRow
代替TableRow
。 Two different things. 两件事。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.