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 4583208
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:10:58+00:00 2026-05-21T21:10:58+00:00

I have a fairly simple web application that gets a list of items from

  • 0

I have a fairly simple web application that gets a list of items from a database (in a DataTable), and binds a view of that DataTable to a Repeater.

When converting my DataTable to a List (which is done in a class library), Page Load fires a second time! Walking though the debugger, the same items are in the list that were in the DataTable.

The only code in my page was:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            rptOffers.DataSource = DataAccess.GetOfferList(offerId); // returns List<T>
            rptOffers.DataBind();
        }
    }

    public static List<OfferItem> GetOfferList(int offerId)
    {
        DataTable dtOffers = GetOfferData(offerId);
        List<OfferItem> offers = new List<OfferItem>();

        // loop throw all of the offers
        foreach (DataRow dr in dtOffers.Rows)
        {
            // add each offer to the List<>
            OfferItem currentOffer = new OfferItem();

            // initialize the OfferItem properties...

            offers.Add(currentOffer);
        }

        return offers;
    }

When I change it back to this, it works fine:

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            rptOffers.DataSource = DataAccess.GetOfferItems(offerId);
            rptOffers.DataBind();
        }
    }

Is there anything else I need to do in my List to keep it from running Page Load again?

  • 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-21T21:10:58+00:00Added an answer on May 21, 2026 at 9:10 pm

    I have experienced this issue when AutoEventWireup is set to true in my .aspx file

        <%@ ... AutoEventWireup="True" ...  %>
    

    and my InitializeComponent function still contains a hookup for Page_Load

        private void InitializeComponent()
        {  
            this.Load += new System.EventHandler(this.Page_Load);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly simple CRUD web application (C#/ASP.NET) that runs fine in Firefox,
I have a web application that uses a fairly large table (millions of rows,
I have a fairly simple const struct in some C code that simply holds
Let's say I have a fairly simple app that lets users store information on
I have the following (fairly) simple JavaScript snippet that I have wired into Greasemonkey.
I have a fairly small MySQL database (a Textpattern install) on a server that
I've written a fairly simple little C# web service, hosted from a standalone EXE
I work on a fairly simple but large two-tier application that consists approximately 40
Say I want to have a simple web app that takes some user input,
I have a fairly simple game that works perfectly on every version now up

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.