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

  • Home
  • SEARCH
  • 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 6914859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:24:06+00:00 2026-05-27T09:24:06+00:00

I have been reading about the Page LifeCycle. I understand the LifeCycle, however, it’s

  • 0

I have been reading about the Page LifeCycle. I understand the LifeCycle, however, it’s not clear on what to do, and when to do it. The problem is I use Page_Load to get database values, and set form fields. I use a button’s onClick method to update the database. However, the form fields text properties were set during Page_Load, so it’s really only updating the database with the OLD values.

Page_Load: I gather data, and set control text properties to reflect data.
Button_onClick: I update the database from the form
Problem: It’s updating values gathered from Page_Load and not the actual form.

Certainly, I am not supposed to perform everything in the Page_Load. So where am I going wrong during this process?

  • 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-05-27T09:24:07+00:00Added an answer on May 27, 2026 at 9:24 am

    Page_Load

    If you are loading your database data in the Page_Load event, the very first thing to do is to wrap it within a if (!IsPostBack) statement.

    IsPostBack
    Gets a value that indicates whether the page is being rendered for the
    first time or is being loaded in response to a postback.

    http://msdn.microsoft.com/en-us/library/system.web.ui.page.ispostback.aspx

    So IsPostBack = true when the page cycle is the result of postback.

    In your Page_Load, you should only gather your data when IsPostBack = false, not on every page load.

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // gather your data here
        }
    }
    

    Setting fields

    I personnaly prefer to set the fields content on the PreRender event handler (but honnestly i don’t know it should/must be done there, it just seems more logic to me).

    PreRender is executed after your postback events (click on a button, drop-down selection change…) so it ensures that your updates and more generally data modifications are done before rendering the page.

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

Sidebar

Related Questions

i have been reading about multiple inheritance What is the exact problem with multiple
I have been reading page after page after page about the benefits of using
For years I've been reading about XML and I have just not quite grokked
I have been reading a lot about how and why to use an MVC
I have been reading about creating an RPM for Python 2.6.4. In this page:
I have been reading about the differences between Table Variables and Temp Tables and
I have been reading about collision detection in games on stackoverflow and other sites.
I have been reading about the continuation passing style programming technique (C# 3.0 implementation).
I have been reading about Quicksort and found that sometimes it' s referred to
I have been reading about Scala for a while and even wrote some small

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.