简体   繁体   中英

how to hide columns in ASP.NET webform

In my PrinterPackage. file i have the following : 文件具有以下

<%@ Register Src="~/ProvisionControls/DeferredTaxRollforwardControl.ascx" TagPrefix="uc9" TagName="DeferredTaxesRollforwardControl" %> 
   ...
   ...
 <div>
    <uc9:DeferredTaxesRollforwardControl ID="DeferredTaxesRollforwardControl1" runat="server" />
 </div>

which calls the control file 'DeferredTaxRollforwardControl. ' 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>

I am trying to display the table and also hide some of the columns using the following code in my PrinterPackage. file : 文件:

 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 and gives me a null value instead. ,而是给了我一个空值。 How can i import the data from the TableRow into and then hide whatever columns i want to hide? 的数据导入 ,然后隐藏我要隐藏的任何列?

@user1319424: Rather than already creating table, use place holder and then create dynamic table and bind that table to a placeholder.

Refer below link: http://www.dotnetcurry.com/ShowArticle.aspx?ID=135

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">

And use System.Web.UI.HtmlControls.HtmlTableRow instead of TableRow . Two different things.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM