• 0

ASP.NET - Gridview not refreshing on Postback


Question

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!

3 answers to this question

Recommended Posts

  • 0
  clonk said:
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.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Aiarty Image Enhancer for PC & Mac (worth $85) free offer ends today June 8 by Steven Parker Claim your complimentary eBook worth $85 for free, before the offer ends today June 8. Get Aiarty Image Enhancer to restore and upscale images to 32K with more details. Make your images and photos larger, sharper and clearer with AI. Tired of the tiny, blurry or low-resolution images downloaded from web or grainy pictures taken by old smartphones? Aiarty Image Enhancer comes to help you out. Leveraging tailored AI models and deep learning algorithms, it can transform any images, photos and AI arts into high-quality visuals with exceptional clarity and realistic details. No matter you’re enhancing web graphics, restoring cherished family memories, or preparing visuals for creative projects, Aiarty can produce studio-quality results in just a few clicks. Get it now to transform your images to stunning masterpieces at zero cost! Key Features: Upscale: enlarge images and photos to 4K/8K/32K for printing, archiving, sharing, displaying, or more. More details: generate more realistic details for hair, fur, feature, skin textures and so on, ensuring crystal-clear pixels. Restore face with faithful details, perfect for portraits, selfies, old photos, group shot. 4-in-1 enhancement: deblur, denoise, dejpeg and upscale image in one click. Batch process. Enhance 3000+ images at once, streamlining image editing workflow. Fast & Simple. Upscale 100 images in 2 minutes with just one click. No skills needed. Trained on 6.78 million images. Optimized for NVIDIA, AMD, and Intel GPUs & CPUs. The exclusive offer ends on June 8th. Don't miss out – grab your free licensed copy today. How to get it Please ensure you read the terms and conditions to claim this offer. Complete and verifiable information is required in order to receive this free offer. If you have previously made use of these free offers, you will not need to re-register. While supplies last! Download Aiarty Image Enhancer for PC/Mac (worth $85) for free Offered by Digiarty WinXDVD, view other free resources The below offers are also available for free in exchange for your (work) email: Winxvideo AI V3.0 Lifetime License for PC ($69.95 Value) FREE – Expires 6/8 Aiarty Image Enhancer for PC/Mac ($85 Value) FREE – Expires 6/8 Solutions Architect's Handbook, Third Edition ($42.99 Value) FREE – Expires 6/10 AI and Innovation ($21 Value) FREE – Expires 6/11 Unruly: Fighting Back when Politics, AI, and Law Upend [...] ($18 Value) FREE - Expires 6/17 SQL Essentials For Dummies ($10 Value) FREE – Expires 6/17 Continuous Testing, Quality, Security, and Feedback ($27.99 Value) FREE – Expires 6/18 VideoProc Converter AI v7.5 for FREE (worth $78.90) – Expires 6/18 Macxvideo AI ($39.95 Value) Free for a Limited Time – Expires 6/22 The Ultimate Linux Newbie Guide – Featured Free content Python Notes for Professionals – Featured Free content Learn Linux in 5 Days – Featured Free content Quick Reference Guide for Cybersecurity – Featured Free content We post these because we earn commission on each lead so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. Other ways to support Neowin The above deal not doing it for you, but still want to help? Check out the links below. Check out our partner software in the Neowin Store Buy a T-shirt at Neowin's Threadsquad Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: An account at Neowin Deals is required to participate in any deals powered by our affiliate, StackCommerce. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through the branded deals site.
    • You will find sketch and clone apps on both the Play Store and the App Store contrary to what Google and Apple will tell you. This fact negates their argument for why there shouldn't be other app stores and so on, it's BS at the end.
    • I ran the powershell script and it did not "recreate the inetpub directory if it has been deleted" I rebooted several times and also tried re running the script. I had to click y three times when I ran it initially as well, now running it just returns to a new poweshell line with no errors but still no directory recreated. meh
    • So? What matters for the masses is the default experience. And in their own ad block implementation they whitelist their ad platform by default. What they care about is making their ad platform more relevant and a good way to do that in their own browser implementation is to blacklist google's platform (lowering its market share) and whitelist theirs (increasing its market share).
    • This, plus loved it as a cameo on 6 underground  
  • Recent Achievements

    • First Post
      viraltui earned a badge
      First Post
    • Reacting Well
      viraltui earned a badge
      Reacting Well
    • Week One Done
      LunaFerret earned a badge
      Week One Done
    • Week One Done
      Ricky Chan earned a badge
      Week One Done
    • Week One Done
      maimutza earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      482
    2. 2
      +FloatingFatMan
      264
    3. 3
      snowy owl
      238
    4. 4
      ATLien_0
      231
    5. 5
      Edouard
      177
  • Tell a friend

    Love Neowin? Tell a friend!