Friday, September 2, 2016

dynamically creating html table and binding to table in aspx page

aspx page code


 <table id="tblCTC_Data" runat="server">
                            <tr id="tdrCTCData_Header">
                                <td runat="server">Description fo Class Shares
                                </td>
                                <td runat="server">(a) Immediately before 1 January 2011
                                </td>
                                <td runat="server">(b) Where the company became a resident since 1 January 2011
                                </td>
                                <td runat="server">Add Considiration received or accrued for the issue of shares by the company
                                </td>
                                <td runat="server">Deduct amount transferred to holders of shares
                                </td>
                                <td runat="server">Deduct reduction as a result of the application of s42
                                </td>
                                <td runat="server">Deduct reduction as a result of the application of s44
                                </td>
                                <td runat="server">Deduct reduction as a result of the application of s46
                                </td>
                                <td runat="server">Balance of contributed tax capital at the end of the assesment
                                </td>
                            </tr>
                        </table>



aspx.cs page code


            tblCTC_Data.Rows.Clear();
            HtmlTableRow headerRow = new HtmlTableRow();
            headerRow.Cells.Add(new HtmlTableCell() { InnerText = "Description fo Class Shares" });
            headerRow.Cells.Add(new HtmlTableCell() { InnerText = "(a) Immediately before 1 January 2011" });
            headerRow.Cells.Add(new HtmlTableCell() { InnerText = "(b) Where the company became a resident since 1 January 2011" });
            headerRow.Cells.Add(new HtmlTableCell() { InnerText = "Add Considiration received or accrued for the issue of shares by the company" });
            headerRow.Cells.Add(new HtmlTableCell() { InnerText = "Deduct amount transferred to holders of shares" });
            headerRow.Cells.Add(new HtmlTableCell() { InnerText = "Deduct reduction as a result of the application of s42" });
            headerRow.Cells.Add(new HtmlTableCell() { InnerText = "Deduct reduction as a result of the application of s44" });
            headerRow.Cells.Add(new HtmlTableCell() { InnerText = "Deduct reduction as a result of the application of s46" });
            headerRow.Cells.Add(new HtmlTableCell() { InnerText = "Balance of contributed tax capital at the end of the assesment" });

            foreach (HtmlTableCell c in headerRow.Cells)
            {
                c.Style.Add("font-weight", "bold");
            }

            tblCTC_Data.Rows.Add(headerRow);

            if (_rootCustomer.ReturnDetail.CorporateIncomeTaxReturn.CompanyDetails.ContributedTaxCapitalDetails.Count > 0)
            {
                foreach (CorporateIncomeTaxReturnStructureCompanyDetailsContributedTaxCapitalDetail xDataTable in
                _rootCustomer.ReturnDetail.CorporateIncomeTaxReturn.CompanyDetails.ContributedTaxCapitalDetails)
                {
                    HtmlTableRow newRow = new HtmlTableRow();
                    newRow.Cells.Add(new HtmlTableCell() { InnerText = xDataTable.ShareClassDescription.ToString() });
                    newRow.Cells.Add(new HtmlTableCell() { InnerText = xDataTable.Before1January2011Amt.ToString() });
                    newRow.Cells.Add(new HtmlTableCell() { InnerText = xDataTable.After1January2011Amt.ToString() });
                    newRow.Cells.Add(new HtmlTableCell() { InnerText = xDataTable.ConsiderationReceivedForShareIssueAmt.ToString() });
                    newRow.Cells.Add(new HtmlTableCell() { InnerText = xDataTable.TransferredToHoldersAmt.ToString() });
                    newRow.Cells.Add(new HtmlTableCell() { InnerText = xDataTable.ReductionApplicationS42Amt.ToString() });
                    newRow.Cells.Add(new HtmlTableCell() { InnerText = xDataTable.ReductionApplicationS44Amt.ToString() });
                    newRow.Cells.Add(new HtmlTableCell() { InnerText = xDataTable.ReductionApplicationS46Amt.ToString() });
                    newRow.Cells.Add(new HtmlTableCell() { InnerText = xDataTable.BalanceEndOfYearAmt.ToString() });
                    tblCTC_Data.Rows.Add(newRow);
                }

            }





same code for asp.net table

.aspx page

  <asp:Table ID="tblCTC" runat="server" Width="794px" BorderStyle="Solid" BorderWidth="3px">
                <asp:TableRow ID="thrCTC_Description" runat="server" BackColor="Gray" ForeColor="White">
                    <asp:TableCell Font-Size="XX-Small" ID="thcCTC_Description" runat="server" ColumnSpan="2">
                        Contributed Tax Capital
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow ID="tdrCTC_CTCDetails_GrossIncomeAmt" runat="server" Width="794px">
                    <asp:TableCell Font-Size="XX-Small">
                        <asp:Table runat="server" ID="tblCTC_Data">
                            <asp:TableRow ID="tdrCTCData_Header" runat="server">
                                <asp:TableCell>Description fo Class Shares</asp:TableCell>
                                <asp:TableCell>(a) Immediately before 1 January 2011</asp:TableCell>
                                <asp:TableCell>(b) Where the company became a resident since 1 January 2011</asp:TableCell>
                                <asp:TableCell>Add Considiration received or accrued for the issue of shares by the company</asp:TableCell>
                                <asp:TableCell>Deduct amount transferred to holders of shares</asp:TableCell>
                                <asp:TableCell>Deduct reduction as a result of the application of s42</asp:TableCell>
                                <asp:TableCell>Deduct reduction as a result of the application of s44</asp:TableCell>
                                <asp:TableCell>Deduct reduction as a result of the application of s46</asp:TableCell>
                                <asp:TableCell>Balance of contributed tax capital at the end of the assesment</asp:TableCell>
                            </asp:TableRow>
                        </asp:Table>
                    </asp:TableCell>
                </asp:TableRow>
            </asp:Table>




aspx.cs page code:

    tblCTC_Data.Rows.Clear();
            //HtmlTableRow headerRow = new HtmlTableRow();
            System.Web.UI.WebControls.TableRow headerRow = new System.Web.UI.WebControls.TableRow();
            headerRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = "Description fo Class Shares" });
            headerRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = "Description fo Class Shares" });


            //headerRow.Cells.Add(new HtmlTableCell() { InnerText = "Description fo Class Shares" });
            headerRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = "(a) Immediately before 1 January 2011" });
            headerRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = "(b) Where the company became a resident since 1 January 2011" });
            headerRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = "Add Considiration received or accrued for the issue of shares by the company" });
            headerRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = "Deduct amount transferred to holders of shares" });
            headerRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = "Deduct reduction as a result of the application of s42" });
            headerRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = "Deduct reduction as a result of the application of s44" });
            headerRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = "Deduct reduction as a result of the application of s46" });
            headerRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = "Balance of contributed tax capital at the end of the assesment" });

            foreach (HtmlTableCell c in headerRow.Cells)
            {
                c.Style.Add("font-weight", "bold");
            }
            //tblCTC_Data.Rows.Add()
            tblCTC_Data.Rows.Add(headerRow);

            if (_rootCustomer.ReturnDetail.CorporateIncomeTaxReturn.CompanyDetails.ContributedTaxCapitalDetails.Count > 0)
            {
                foreach (CorporateIncomeTaxReturnStructureCompanyDetailsContributedTaxCapitalDetail xDataTable in
                _rootCustomer.ReturnDetail.CorporateIncomeTaxReturn.CompanyDetails.ContributedTaxCapitalDetails)
                {

                    System.Web.UI.WebControls.TableRow newRow = new System.Web.UI.WebControls.TableRow();
                    newRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = xDataTable.ShareClassDescription.ToString() });
                    newRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = xDataTable.Before1January2011Amt.ToString() });
                    newRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = xDataTable.After1January2011Amt.ToString() });
                    newRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = xDataTable.ConsiderationReceivedForShareIssueAmt.ToString() });
                    newRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = xDataTable.TransferredToHoldersAmt.ToString() });
                    newRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = xDataTable.ReductionApplicationS42Amt.ToString() });
                    newRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = xDataTable.ReductionApplicationS44Amt.ToString() });
                    newRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = xDataTable.ReductionApplicationS46Amt.ToString() });
                    newRow.Cells.Add(new System.Web.UI.WebControls.TableCell() { Text = xDataTable.BalanceEndOfYearAmt.ToString() });
                    tblCTC_Data.Rows.Add(newRow);
                }

            }




No comments:

Post a Comment