You must Sign In to post a response.
  • Category: ASP.NET

    Dynamic table and postback


    I have an asp Table control in a page and the rows are creating dynamically. I generating pdf file when clicking on button and downloading it(the values are taking from the dynamically created rows.).In postback I should refill the table rows again. otherwise the pdf file will be blank.Please provide me a solution.(ie,Table is losing its rows that was added dynamically, on PostBack )
  • #767555
    Question is not clear, But try this store the created rows values in the session/view and use them for creating the PDF file.
    Shivshanker Cheral
    "If you share your assets (money etc..) it will decrease, But if you share your knowledge it will increase!!! ".

  • #767558
    I am storing session in mssql. So the object is not serializable.

    In postback the table contains only the header row. But it will display all rows in web pdf we will get only blank records.

  • #767570

    After postback you loose your stored data right?

    This is the reason Microsoft introduce the concept called Statemanagement, using this concept you can maintain state of your controls. We have different types of StateManagment controls available as per Microsoft based on our need we need to choose which one is needed in our case.


    These all are maintain data after postback but each of the concept having some extra features based on your requirement you want to maintain state with in page, my suggestion is you can use ViewState Management, using this you can maintain your data without loose it.


    storing into ViewState
    ViewState["Data"]=//your data;

    Get back from ViewState
    DataTable dt=ViewState["Data"] as DataTable// I assume that you are stored DataTable data

    Hope this helps you....

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #767597
    Dynamic controls must be re-added to the form on each postback. Typically this is done during the Init phase of the page's lifecycle. The controls that you have added dynamically DO actually have ViewState. When the appropriate control is re-added to the control tree using the exact same ID it had before, it should reappear with the values that were persisted in ViewState
    check out below link for more details

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • Sign In to post your comments