Adding cell to the tble

Discussion in 'ASP .Net' started by simon, Apr 7, 2004.

  1. simon

    simon Guest

    I have table with rows:

    <asp:Table Runat="server" ID="tbl_MPlan">
    <asp:TableRow Runat="server" ID="Tablerow0"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow1"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow2"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow3"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow4"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow5"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow6"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow7"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow8"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow9"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow10"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow11"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow12"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow13"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow14"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow15"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow16"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow17"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow18"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow19"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow20"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow21"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow22"></asp:TableRow>
    <asp:TableRow Runat="server" ID="Tablerow23"></asp:TableRow>
    </asp:Table>
    Now I would like to add the cells when page_onload event is fired:

    Dim c As New TableCell
    c.Text = "uuuu"
    tbl_MPlan.Rows(0).Cells.Add(c)
    tbl_MPlan.Rows(1).Cells.Add(c)
    tbl_MPlan.Rows(2).Cells.Add(c)
    tbl_MPlan.Rows(3).Cells.Add(c)
    ....
    ....

    But only 1 cell is added.
    Why?
     
    simon, Apr 7, 2004
    #1
    1. Advertisements

  2. simon

    Guest Guest

    Simo

    try this..

    Dim x As Intege

    For x = 0 To 2
    Dim c As New TableCell(
    c.Text = "uuuu
    tbl_MPlan.Rows(x).Cells.Add(c
    Nex

    also, you can add the rows dynamicall

    Dim x As Intege

    For x = 0 To 2
    Dim c As New TableCell(
    Dim r As New TableRow(
    c.Text = "uuuu
    r.Cells.Add(c
    r.ID = "TableRow" &
    tbl_MPlan.Rows.Add(r
    Nex
     
    Guest, Apr 7, 2004
    #2
    1. Advertisements

  3. simon

    simon Guest

    Thank you, it works.
    Obvioussly you have to create new cell every time you add it to the row.
    I created only once and than try to add it more times.

    I have another question.
    If I have 3x3 table and I would like to insert new column (cell) on the
    second place.
    How can I do that?

    Thank you,
    Simon
     
    simon, Apr 8, 2004
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.