postback for dynamically created table

Discussion in 'ASP .Net' started by martin, May 14, 2004.

  1. martin

    martin Guest

    Hi,

    I have the following code in my page load event that creates a table on the
    web page.
    The trouble is that after a postback such as a button click on the page the
    table is not retained but ignored.

    If Not IsPostBack() Then
    Response.Write("This is NOT a postback<br>")
    Dim tblMain As New Table
    Dim tblRow As New TableRow
    Dim tblCell As New TableCell

    tblMain.Rows.Add(tblRow)
    tblCell.Text = "hello"
    tblMain.Rows(0).Cells.Add(tblCell)

    Controls.Add(tblMain)
    Else
    Response.Write("This is a postback<br>")
    End If


    I would apprecaite advice on how to redisplay the table without actually
    re-building it everytime the page re loads.

    cheers

    martin.
     
    martin, May 14, 2004
    #1
    1. Advertising

  2. martin

    avnrao Guest

    any dynamically created controls should be created on every postback. the
    best place to keep them is in Init method of the page.

    Av.
    "martin" <> wrote in message
    news:%...
    > Hi,
    >
    > I have the following code in my page load event that creates a table on
    > the
    > web page.
    > The trouble is that after a postback such as a button click on the page
    > the
    > table is not retained but ignored.
    >
    > If Not IsPostBack() Then
    > Response.Write("This is NOT a postback<br>")
    > Dim tblMain As New Table
    > Dim tblRow As New TableRow
    > Dim tblCell As New TableCell
    >
    > tblMain.Rows.Add(tblRow)
    > tblCell.Text = "hello"
    > tblMain.Rows(0).Cells.Add(tblCell)
    >
    > Controls.Add(tblMain)
    > Else
    > Response.Write("This is a postback<br>")
    > End If
    >
    >
    > I would apprecaite advice on how to redisplay the table without actually
    > re-building it everytime the page re loads.
    >
    > cheers
    >
    > martin.
    >
    >
     
    avnrao, May 14, 2004
    #2
    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. CS Wong
    Replies:
    1
    Views:
    2,857
    Jeffrey Palermo [MCP]
    Oct 29, 2004
  2. ree32
    Replies:
    4
    Views:
    818
    ree32
    Feb 21, 2005
  3. ree32
    Replies:
    1
    Views:
    374
    =?Utf-8?B?SmltIEhlYXZleQ==?=
    Feb 18, 2005
  4. msimmons
    Replies:
    0
    Views:
    514
    msimmons
    Jul 16, 2009
  5. T.G.
    Replies:
    2
    Views:
    1,113
Loading...

Share This Page