Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi I have a Training Html table.Some textbox and one add button in this table . When i click Add Traning(If Requird) button then Another Html table create with same data.How can i solve this problem in csharp.pls help me.
ASP.NET
<table class="TableWorkArea" border="1px" cellpadding="3" style="border-collapse: collapse">
                            <tr>
                                <td class="TableHeading" colspan="4">
                                    SECTION G : PROFESSIONAL TRAINING</td>
                            </tr>
                            <tr>
                                <td class="TDLeftLabel" width="18%">
                                    Training On
                                </td>
                                <td class="TDRightInput" width="32%">
                                    <asp:TextBox runat="server" ID="txtTrainingOn"
                                           CssClass="TextBoxFixed" TabIndex="14" Width="196px"></asp:TextBox>
                                </td>
                             </tr>
                                <tr>
                                <td class="TDLeftLabel" width="18%">
                                  Training Duration
                                </td>
                                <td class="TDRightInput" width="32%">
                                   <asp:TextBox runat="server" ID="txtTrainingDuration"  CssClass="TextBoxFixed" TabIndex="14" Width="196px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="TDLeftLabel" width="18%">
                                    Other Info [If Any]
                                </td>
                                <td class="TDRightInput" colspan="3">
                                    <asp:TextBox runat="server" ID="txtTraningOther" CssClass="TextBoxFixed"  Width="196px"></asp:TextBox>

                                </td>
                            </tr>

                            <tr>
                                <td class="TDLeftLabel" colspan="4"><asp:Button ID="btnTraningAdd" runat="server" Text="Add Traning(If Requird)" /></td>

                            </tr>
                             </table>
Posted

1 solution

You can use Dynamic Controls for this ::


protected void btnTraningAdd_Click(object sender, EventArgs e)
   {
       HtmlTable ht = new HtmlTable();
       HtmlTableRow tr = new HtmlTableRow();
       HtmlTableCell tc = new HtmlTableCell();
       tc.InnerText = "hello";
       ht.Rows.Add(tr);

       tr.Cells.Add(tc);
       PlaceHolder1.Controls.Add(ht);
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900