• 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 honestly think this does not make any noticable difference to anyone with a PC with average specs.
    • OpenAI takes down all traces of Jony Ive "io" deal following court order by David Uzondu Early this month, we reported that OpenAI was working on a mobile gadget in the form of a screenless, wearable device, born from a newfound partnership (friendship?) between renowned former Apple designer Jony Ive and OpenAI CEO Sam Altman. The announcement came with a video that had the two men talking about the future of technology. Well, that video has now been made private on YouTube, and the original announcement page has been taken down. The whole thing is on pause because of a simple trademark dispute. OpenAI was forced to pull the materials following a court order. If you visit the original announcement page, it now says: Despite the legal hassle over the name, the actual business deal seems safe. According to Bloomberg's Mark Gurman, the acquisition itself is unaffected by the complaint. So, who is iyO (pronounced eye-oh), the other party in this mess? If the name sounds unfamiliar, its background will not. This iyO company is an independent startup that graduated from X, Alphabet's moonshot factory, and yes, that is the same Alphabet, the parent company of Google. iyO claims to be on a mission to bring "natural language computing" to the masses. A quick look shows two products listed on its website: the Vad Pro, a high-end wired audio device for professionals, and iyO One, a set of AI-powered earbuds the company is calling the "world's first audio computer." A judge reportedly found its trademark lawsuit against OpenAI credible enough to issue the restraining order, suggesting the ChatGPT creator's video could create genuine consumer confusion between the two similarly named ventures.
    • I've set since XP - Best performance in the Performance settings. 11 included. I enable only the show shadows after that, so I can see better fonts and mouse.. But hardly I can say I can see a difference today.
    • Yeah this kinda means nothing to me if it's going to be the same mess as HDMI 2.1 where it was difficult to know what features you were getting. It was way too confusing, designed to fool us into thinking we was getting something better with the higher number when a lot of the times we didn't get anything better because companies can add and remove features at will, which if that is the case for 2.2, then who cares lol.
    • Someone wrote a script to block 'brainrot' content online using an $8 smart plug by Usama Jawad Original image via Neil Chen Many people use smart plugs nowadays due to the various advantages they offer, including automation, integration with mobile software, increased home security, better energy efficiency, and compatibility with other smart products. However, a smart plug customer has gone a step further by enhancing their hardware in a way that it blocks them from viewing "brainrot" content online, or any website, for that matter. As seen in a popular thread over on Hacker News, a person known as "NWChen" has written a script that connects to the $8 Kasa Smart Wi-Fi Plug Mini and utilizes it to restrict access to websites of your choice. In essence, this plug then acts as a physical switch that you can toggle to visit certain websites. NWChen's main motivation behind this initiative was to avoid brainrot, with examples listed as X (formerly known as Twitter), Instagram, YouTube, and Reddit in their blog post. In terms of technical functionality, the smart plug connects to Wi-Fi (obviously) and hosts a physical switch that can be used to turn it on and off. NWChen's script connects to the smart plug via an API and then polls its state. If it's on, websites of your choice get restricted and you can't open them anymore, until you physically get up and turn off the plug, or remove the website from you blocklist. NWChen has recommended plugging in the hardware far away from you so there is sufficient resistance in turning off the plug. In the thread, many have praised this invention, believing that the nature of this mechanism provides enough hurdles where you'd rather just not visit the problematic websites anymore. However, some have noted that "those without self control cannot be trusted if they hold the switch". Some have also highlighted a problem where a user can simply stop the script's execution without much friction. Overall, it's a fairly interesting setup, even if it's fairly rudimentary in nature. Configuring this physical block with a Kasa smart plug is fairly easy. You can simply download the script from the laptop-brick GitHub project here, install it, get the IP address of your smart plug, and then use it when you're executing the script. You can modify the blocklist using a dedicated file present inside the GitHub project.
  • Recent Achievements

    • Conversation Starter
      Brett76 earned a badge
      Conversation Starter
    • One Month Later
      Miguel Batista earned a badge
      One Month Later
    • Dedicated
      moojay67 earned a badge
      Dedicated
    • One Month Later
      Jim Dugan earned a badge
      One Month Later
    • First Post
      Johnny Mrkvička earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      653
    2. 2
      Michael Scrip
      229
    3. 3
      ATLien_0
      220
    4. 4
      Steven P.
      151
    5. 5
      Xenon
      144
  • Tell a friend

    Love Neowin? Tell a friend!