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>
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>
I am trying to display the table and also hide some of the columns using the following code in my PrinterPackage.aspx.cs 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 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?
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.
The code behind cannot see the
<tr>you created because it’s not a server control. Add therunat="server"attribute to the<tr>:And use
System.Web.UI.HtmlControls.HtmlTableRowinstead ofTableRow. Two different things.