Add row to asp:table : Table « Asp Control « ASP.Net






Add row to asp:table

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
    Dim TheRow = New TableRow
    Dim TheProduct = New TableCell
    Dim TheQuantity = New TableCell
    TheProduct.Text = txtProduct.Text
    TheQuantity.Text = txtQuantity.Text
    TheRow.Cells.Add(TheProduct)
    TheRow.Cells.Add(TheQuantity)
    Table1.Rows.Add(TheRow)
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Creating an HTML Table Using the Table Control</TITLE>
</HEAD>
<BODY LEFTMARGIN="40">
<form runat="server">
<asp:table 
    id="table1" 
    runat="server"
>
    <asp:tablerow>
        <asp:tablecell>
        <B>Product</B>
        </asp:tablecell>
        <asp:tablecell>
        <B>Quantity</B>
        </asp:tablecell>
    </asp:tablerow>
</asp:table>
<BR><BR>
Product:
<BR>
<asp:textbox 
    id="txtProduct" 
    runat=server 
/>    
<BR>
Quantity:<BR>
<asp:textbox 
    id="txtQuantity" 
    runat=server 
/>    
<BR>
<asp:button 
id="butSubmit"
text="OK"
onclick="SubmitBtn_Click" 
runat="server"
/>
</form>
</BODY>
</HTML>
           
       








Related examples in the same category

1.asp:table with static data
2.Add asp:tablecell
3.Layout controls in an asp:Table
4.Table Footer Row