|
-
May 15th, 2008, 09:20 PM
#1
Thread Starter
Hyperactive Member
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?
-
May 16th, 2008, 06:05 AM
#2
-
May 16th, 2008, 02:14 PM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|