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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:46:15+00:00 2026-05-12T18:46:15+00:00

I have a gridview, the contents of which are provided by accessdatasource the data

  • 0

I have a gridview, the contents of which are provided by accessdatasource the data displayed is dependant on a dropdown list which has a postback event

  • The page loads
  • User selects an item from the dropdown
  • page reloads with new data in the gridview

So far so good

I have then added a textbox to the grid view (no I can’t to use the standard “edit” link)
The textbox is in a itemtemplate

this textbox contains editable data for the user to update and send back to the server with a click of the update button.

The problem is if I change the selection in the dropdown the gridview updates as it should but the textboxes retain the old value even though they are bound with <%# Bind(“vr_total”) %>

I can only assume that this is caused by the postback data and that the data is overwritten after the binding occurs. (otherwise the bind would overwrite the old unwanted data)

Can someone please explain how I can change this behaviour.

viewstate is set to false

I am new to .net and c#

DC

A further development..

If I replace the <asp:textbox with <input type=”text” value=”<%# Eval(“vr_total”) %>” … > the grid works exactly as expected.

The problem appears to be the gridview populates its child controls when the data is bound but the textbox overwrites it with what was posted (via the postback event on the dropdown) even if its viewstate is disabled.

  • 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-12T18:46:15+00:00Added an answer on May 12, 2026 at 6:46 pm

    Chris,
    Controls have what is known as ControlState, which you can’t disable. The problem you’re encountering is that you’re loading and binding in page load, then an action is being fired afterward.

    The way we work around this problem is to load data in Page_Load and bind data in OnPreRender.

    for example:

    private void Page_Load(object sender, System.EventArgs e)
    {
      grid.DataSource = whatever;
    }
    
    // your dropdown event occurs between these two events
    
    protected override void OnPreRender(EventArgs e)
    {
       grid.DataBind();
    }
    

    To better understand ASP.NET ViewState, check out http://msdn.microsoft.com/en-us/library/ms972976.aspx

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

Sidebar

Related Questions

I have GridView which I can select a row. I then have a button
I have a GridView control in an Asp.net application, that has a <asp:buttonField> of
My current task is an ASP.NET page to display the contents of a data
I have a DataTable which is bound to a GridView. I also have a
I have an android gridview which i'm using some custom scrolling going on in,
I have a list view which contains checkboxes. How I can get if it
I have a GridView where one column is bound to an object property containing
I have a GridView defined like this: <asp:GridView ID=myGridView ruant=server> <asp:BoundField DataField=myField /> <asp:CommandField
I have a gridview like below: <asp:GridView DataKeyNames=TransactionID AllowSorting=True AllowPaging=TrueID=grvBrokerage runat=server AutoGenerateColumns=False CssClass=datatable Width=100%
I have a GridView that I would like to bind to an ObjectDataSource. I

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.