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. Advertising

  2. 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
    =?Utf-8?B?SmF5?=, Apr 7, 2004
    #2
    1. Advertising

  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

    "Jay" <> wrote in message
    news:D...
    > Simon
    >
    > try this...
    >
    > Dim x As Integer
    >
    > For x = 0 To 23
    > Dim c As New TableCell()
    > c.Text = "uuuu"
    > tbl_MPlan.Rows(x).Cells.Add(c)
    > Next
    >
    > also, you can add the rows dynamically
    >
    > Dim x As Integer
    >
    > For x = 0 To 23
    > Dim c As New TableCell()
    > Dim r As New TableRow()
    > c.Text = "uuuu"
    > r.Cells.Add(c)
    > r.ID = "TableRow" & x
    > tbl_MPlan.Rows.Add(r)
    > Next
    >
    >
    simon, Apr 8, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. news.rcn.com
    Replies:
    1
    Views:
    9,659
    Chris Smith
    Jul 12, 2004
  2. Phillip Roncoroni
    Replies:
    14
    Views:
    1,086
    Toby A Inkster
    Apr 5, 2004
  3. Empire City
    Replies:
    3
    Views:
    406
    Empire City
    Apr 30, 2004
  4. Thomasa Gregg
    Replies:
    1
    Views:
    154
    Eliyahu Goldin
    Jun 9, 2004
  5. Arihan Sinha

    Unable to retrieve data from tble

    Arihan Sinha, Sep 24, 2010, in forum: Ruby
    Replies:
    1
    Views:
    105
    Brian Candler
    Sep 24, 2010
Loading...

Share This Page