• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

ASP.NET - Gridview not refreshing on Postback

Question

clonk    2

Guys,

I have this web app that I am developing that is my first project using ASP.NET 2.0, so I am learning a lot as I go. I have run into a particular issue that I am not sure how to best fix. Here is the deal:

On a particular page I have 2 Gridview Controls. Gridview1 shows a list of features an item has, and GridView2 shows a list of features available. Each Gridview control has a template column with checkboxes. In Addition, there a button associated with Gridview1, that when pressed, will remove the checked features from the item. GridView2 has a button for it that will add the checked features to the item. I have all my logic functioning properly, and things are properly assigned and removed, but I can only see this if I navigate away from the page and then come back. These changes are not reflected in the postback when I press either button.

This brings me to my question, what is the best way I can make these Gridview's refresh their data on postback? If it matters, the gridviews are receiving their data from an ObjectDataSource and a custom method that returns a class which extends / implements BaseCollection.

Thanks in advance for any help you can give me!

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
stewright    0
GridView1.DataBind();
GridView1.DataBind();

Share this post


Link to post
Share on other sites
  • 0
clonk    2

I just answered my own question. For those interested, I set the EnableViewState property on the ObjectDataSource to false and this solved my problem. Thanks for looking.

Share this post


Link to post
Share on other sites
  • 0
amrinders87    1
I just answered my own question. For those interested, I set the EnableViewState property on the ObjectDataSource to false and this solved my problem. Thanks for looking.

There must be something else going on. Disabling ViewState generally for databinding controls is not a good thing.

As stewright said, calling the DataBind method will refresh it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.