Results 1 to 3 of 3

Thread: HTML table :New row

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2006
    Posts
    274

    HTML table :New row

    'how to add a new row to existing table row..Im using <asp:table>..with the following code it tends to remove all the previous row then only add in a new row?
    Code:
     Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim m_text As String, m_row As TableRow, m_cell As TableCell, m_date As String, m_time As String
            m_text = TextBox1.Text
            m_date = "" : m_time = "" : getdatetime(m_date, m_time)
            'row one
            m_row = New TableRow
            'left cell
            m_cell = New TableCell
            m_cell.Width = 300
            m_cell.Text = "Date= " & m_date & " <br/>" & _
                         "Time= " & m_time & ""
            m_row.Cells.Add(m_cell)
            'right cell
            m_cell = New TableCell
            m_cell.Width = 700
            m_cell.Text = m_text
            m_row.Cells.Add(m_cell)
            table1.Rows.Add(m_row)
    
        End Sub
    BTW when i type in something in a textbox, all the previous items entered in that textbox will be listed out, how to remove it?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: HTML table :New row

    Moved From FAQ Section

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: HTML table :New row

    You are adding controls dynamically to the table. This means that you need to preserve the viewstate of the row and its textboxes yourself. You will need to recreate the controls that you made in the code you showed us above in the Page Init event. This way, once it is created, the viewstate information can be applied to it and you won't lose your information.

    I suggest that you read this article thoroughly to understand what's happening and how to deal with it.

    http://aspnet.4guysfromrolla.com/articles/092904-1.aspx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width