cant add dynamically created table row to Table

Posted by Shijohnjoseph under ASP.NET on 5/26/2011 | Points: 10 | Views : 1452 | Status : [Member] | Replies : 1
hi ..
please do check my code and give me a solution for adding a TableRow values to a Table
My Coding Part:-
==============
<table id="Table1" runat="server" align="center" class="style31">
<tr>
<td> &nbsp;</td>
</tr> </table>
------------------------
My Code Behind File:-
=====================
TableRow TRow02 = new TableRow();
TableCell TCell02_1 = new TableCell();
Label Lbl_Tariff_No2 = new Label();
Lbl_Tariff_No2.Text = "2";
Lbl_Tariff_No2.ID = "Lbl_Tariff_No2";

TCell02_1.Controls.Add(Lbl_Tariff_No2);

TableCell TCell02_2= new TableCell();
TextBox txt_Tariff_Room2 = new TextBox();
txt_Tariff_Room2.Width=250;

TCell02_2.Controls.Add(txt_Tariff_Room2);

TableCell TCell02_3 = new TableCell ();
TextBox txt_Tariff_Plan2 = new TextBox();
txt_Tariff_Plan2.Width = 93;
TCell02_3.Controls.Add(txt_Tariff_Plan2);


TableCell TCell02_4 = new TableCell ();
TextBox txt_Tariff_Tariff2 = new TextBox();
txt_Tariff_Tariff2.Width = 90;
TCell02_4.Controls.Add(txt_Tariff_Tariff2);


TableCell TCell02_5= new TableCell ();
TextBox Lbl_Tariff_Unit2 = new TextBox();

TCell02_5.Controls.Add(Lbl_Tariff_Unit2);

TableCell TCell02_6 = new TableCell ();
TextBox txt_Tariff_Tax2 = new TextBox();
txt_Tariff_Tax2.Width = 90;
TCell02_6.Controls.Add(txt_Tariff_Tax2);

TableCell TCell02_7 = new TableCell ();
Label Lbl_Tariff_Percent2 = new Label();
Lbl_Tariff_Percent2.Text = "%";
Lbl_Tariff_Percent2.ID = "Lbl_Tariff_Percent2";
TCell02_7.Controls.Add(Lbl_Tariff_Percent2);
TRow02.Cells.Add(TCell02_1);
TRow02.Cells.Add(TCell02_2);
TRow02.Cells.Add(TCell02_3);
TRow02.Cells.Add(TCell02_4);
TRow02.Cells.Add(TCell02_5);
TRow02.Cells.Add(TCell02_6);
TRow02.Cells.Add(TCell02_7);
Table1.Rows.Add(TRow02);

"Personality has the power to open many doors, but character must keep them open"


Responses

Posted by: Ndebata on: 5/26/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
Try to replace your html table with that of ASP.NET Table Control bellow in your ASPX page
<asp:Table ID="Table1" runat="server">

</asp:Table>


Thanks,
Debata

Shijohnjoseph, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response