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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:07:14+00:00 2026-05-18T10:07:14+00:00

I’ve read multiple sources that say Gridview’s do not persist the Gridview.DataSource property on

  • 0

I’ve read multiple sources that say Gridview’s do not persist the Gridview.DataSource property on postback. My understanding is that in term’s of ASP.NET, a postback is any page load that is not the first pageload (see MSDN).

I’ve got a situation with 2 very similar gridviews.

GvOne.DataSource is null on postback.
GvTwo.DataSource is NOT null on postback.

The only big difference outside of a few differing columns is GvOne is populated with the Entity Framework and LINQ. GvTwo is populated by a DataTable filled by a SqlDataAdapter.

Further, GvOne and GvTwo have a TemplateField with a TextBox that I use to gather user input. Both use the same code to pull the TextBox.Text on postback:

TextBox tb = (TextBox)GvOne.Rows[i].FindControl("actualTxt");

GvOne properly gathers tb.Text. GvTwo always finds the tb.Text value to be 0.

Basic Gridview code:

<asp:GridView ID="GvOne" runat="server" AutoGenerateColumns="False">
        <Columns>
        <asp:TemplateField HeaderText="Return">
   <ItemTemplate>
   <asp:TextBox id="actualTxt" runat="server" Text='0' Width="40px"></asp:TextBox>
   </ItemTemplate>      
       </asp:TemplateField> 
         ...
        </Columns>
</asp:GridView>

<asp:GridView ID="GvTwo" runat="server" AutoGenerateColumns="False">
        <Columns>
        <asp:TemplateField HeaderText="Order">
   <ItemTemplate>
   <asp:TextBox id="actualTxt" runat="server" Text='0' Width="40px"></asp:TextBox>
   </ItemTemplate>      
       </asp:TemplateField> 

         ...
        </Columns>
</asp:GridView>

Changing GvTwo to use Entity Framework and LINQ is a potential solution, albeit a major undertaking. Does anyone know what is going on here?

UPDATE (See my comment on Joel Etherton’s Answer)
Due to popular demand here is the code to populate the gridview within Page_Load event for GvTwo (GvOne is similar):

   ordersGV.DataSource = dataSetObject.Tables["activeParts"];
    ordersGV.DataBind();

Searching through the code behind I found no other references to ordersGv.Datasource and no other events that are hooked into associated with the page life cycle.

  • 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-18T10:07:15+00:00Added an answer on May 18, 2026 at 10:07 am

    Gridviews do not persist the datasource across postbacks. If you have a gridview that has a non-null datasource then you must be filling that datasource somewhere in your code. It would be instructive to travel through your event cycle to find where exactly the population of the datasource is occuring on postback.

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

Sidebar

Related Questions

No related questions found

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.