Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8470049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:24:15+00:00 2026-06-10T16:24:15+00:00

I have an ASP.net table, and I am adding Tables rows and cells to

  • 0

I have an ASP.net table, and I am adding Tables rows and cells to it dynamically at run time, and also adding controls (text boxes and labels) to these cells. I am creating and filling these controls at the OnInit event, on hope that they will be automatically saved into view sate. But they are not! on each postback the table is reset and appears empty.

I read many solutions like to save the controls in Cache or in Session or manually add them to view sate and manually save their values to view state, but I want a straighforward solution. Like when u drag drop any asp.net component, and you forget about maintaining its state.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T16:24:17+00:00Added an answer on June 10, 2026 at 4:24 pm

    As tranceporter suggested, you will have to add table control everytime. However, if you want to maintain viewstate between post backs then you need to rebuild the table in the PreInit event, e.g.

    protected void Page_PreInit(object sender, EventArgs e)
    {
        TableRow row = new TableRow();
        TableCell cell = new TableCell();
        cell.Controls.Add(new TextBox());
        row.Cells.Add(cell);
        table.Rows.Add(row);
    }
    

    If the control is created in the PreInit event then the ASP.NET framework will apply the viewstate to the controls for you before the page Init and Load events fire. See here for more details on the ASP.NET page life cycle:

    http://msdn.microsoft.com/en-us/library/ms178472(v=VS.100).aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have dragged a empty asp.net table onto my webform. I generate all the
I have an ASP.NET page and I am generating an HTML table in my
I have an ASP.Net-MVC app using LinqToSql. I have a subcontracts table, a service_lines
I have a table of results in an ASP.Net MVC page where the last
I have the following HTML generated by an ASP.NET repeater: <table> <tr> <td><input type=hidden
Context: ASP.NET MVC 2.0, C#, SQL Server 2008, IIS7 I have 'scheduledMeetings' table in
My application is in ASP.net MVC3. I have a table of elements. An element
I have an ASP.NET site with membership tables in a Main_DB for the site.
Curious whether folks have setup 2 way transactional replication on the tables ASP.NET uses
I'm developing an ASP.Net project. I have an <asp:Table> control on my page, to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.