• 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

    • I had to turn it off a long time ago on my work machine because virtual desktops were brutal when switching. Big thread about it on Microsoft forums. With animations off it's instant. Sucks as I had to uninstall Deskscapes as it requires animations but on my work machine productivity takes precedence.
    • Even though this tweak is basically just a placebo, I still find myself using it fairly often. There are better options out there, but the CrapFixer app https://github.com/builtbybel/CrapFixer is useful for testing and restoring the original state if needed
    • That’s such a heartwarming story — it really shows the strong sense of community Waffle House is known for. If anyone’s curious about what they offer or planning a visit, you can see full menu with updated prices and calories for 2025.
    • I'm not sure I would really call that a hidden setting, and it's been around since Windows XP.
    • Main server is my old gaming PC from years ago.  It was an older AMD Phenom based desktop until last year when I "upgraded" it.  It hosts Nextcloud, Minecraft, Jellyfin and my personal website, and serves as a general purpose backup NAS.  It is apparent in this picture though it needs a good dusting. Operating System: Debian GNU/Linux (stable, but with backports kernel) CPU: AMD FX 8370 GPU: AMD Radeon RX 480 8GB (Used for hardware transcoding in Jellyfin) Memory: 16GB Corsair Vengeance DDR3 @ 1,866 MT/s Boot Drive: Western Digital Blue 500GB SATA SSD Mass Storage: 4 12TB Western Digital Gold HDDs.  Am using mdadm software RAID 5, with an encrypted LUKS/ext4 filesystem on the array.  My "off site backup" is 3 external drives in an encrypted software RAID 0 that I keep stored outside the house and bring in once a month to sync with the internal drives. Storage drive layout: mdadm -> LUKS -> ext4 Secondary server is a Raspberry Pi 4B that hosts PiHole and Wireguard via PiVPN.  I largely use the PiHole not just for ad blocking, but for parental controls on the kids.  I'm actually thinking of upgrading this to an x86 mini PC so I can get secure boot, SMART monitoring of the boot drive, etc. Router is a GL-iNet Flint 2, incoming internet connection is 1Gbps up, 1Gbps down, no data caps.  Fiber to my service pole then ethernet from there into the house. UPS is an APC Back-UPS XS 1500G.  I've had it for ages and had to replace the battery a few times.  The main server monitors it since our power is pretty unreliable (see screenshot) here in eastern Kentucky.  On the occasion the batteries run down the main server will automatically log into the Pi and do a graceful shutdown on it as part of its power down procedure.
  • Recent Achievements

    • First Post
      Johnny Mrkvička earned a badge
      First Post
    • Week One Done
      viraltui earned a badge
      Week One Done
    • One Month Later
      serfegyed earned a badge
      One Month Later
    • Dedicated
      firey earned a badge
      Dedicated
    • Dedicated
      fettermanj earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      656
    2. 2
      ATLien_0
      224
    3. 3
      Michael Scrip
      224
    4. 4
      Xenon
      146
    5. 5
      +FloatingFatMan
      143
  • Tell a friend

    Love Neowin? Tell a friend!