Remember dyanmically built HTMLTables on post back

Posted on 2005-05-11
Last Modified: 2010-04-07
I have two tables which I dynamically create when the page loads. I want to be able to add rows to those tables, but when I do the simple code of adding another row, after the second load the page completely forgets about what the tables looked like on the first load.

Basically, how do I get the page to remember what the page looks like after each post back.

Here is some of my code:
    Private Sub BindSimilarItems()
        Dim row As New TableRow
        Dim itemRow As DataRow

        For Each itemRow In tblSimilarItems.Rows
            Dim cell As New TableCell
            Dim fp As FeaturedProduct = New FeaturedProduct( _
                itemRow.Item("itemNo"), _
                itemRow.Item("picType"), _
                itemRow.Item("picWidth"), _
                itemRow.Item("picHeight"), _
    End Sub
    Private Sub btnSeletMore_Click(ByVal obj As Object, ByVal e As EventArgs) Handles btnSeletMore.Click
        Dim newStyleRow As New TableRow
        Dim newCell As New TableCell
        newCell.Controls.Add(New LiteralControl("HI"))
    End Sub
Question by:abradley81
    1 Comment
    LVL 33

    Accepted Solution

    Not happening, controls do not persist across postbacks.  I would suggest looking into using a DataList, or a Repeater, and defining the ItemTemplate.  These will persist.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now