Solved

Gridview inside UpdaePanel does not update

Posted on 2010-08-30
6
423 Views
Last Modified: 2013-11-08
Hi
This is so simple yet difficult :)
Ihave the following
- updatePanel with UpdateMode="Conditional"
- Gridview inside the updatePanel with EnableSortingAndPagingCallbacks="True"  
- Button inside the updatePanel I called it updateBtn
- ScriptManager with EnablePartialRendering="True"

In the server side, at   protected void updateBtn_Click(object sender, EventArgs e) method
// execute query
Gridview.DataBind();
Gridview.SelectedIndex = -1;
updatePanel.Update();

The problem is: When I click the updateBtn button, The Gridview does not update, unless I click the button again or I click on a page number.

Q: How can I refresh a gridview using a button and an update panel
0
Comment
Question by:HandyManny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 7

Expert Comment

by:urir10
ID: 33562420
try including that for your update panel

  <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="updateBtn" EventName="Click" />
                     
   </Triggers>
0
 

Author Comment

by:HandyManny
ID: 33562443
@urir10:
I have already included the button as a trigger.
The button is working, but the gridview does not refresh unless I click the button twice or I click on a page number.
0
 
LVL 7

Accepted Solution

by:
urir10 earned 500 total points
ID: 33562495
do u have any other update panel as parents to that update panel?
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

Author Comment

by:HandyManny
ID: 33562521
@urir10: No
I am pretty sure that the problem is realted to the post back thing.
You see, when I click the button again, the gridview refreshed. The same thing happens when I click on a page number of the gridview.

But I cannot figure it out because I am not expert with asp.net page life cycle  
0
 
LVL 7

Assisted Solution

by:urir10
urir10 earned 500 total points
ID: 33562538
can u post the code for the button as well as the markup for the page?
0
 

Author Comment

by:HandyManny
ID: 33562695
Well Thank you very much.
When I tried to re-write the code into simple version, I found the mistake.
The reason was the following:
I forgot to clear the data source before I execute the query. So the gridview is updated. However, the new data are appended at the bottom of the data source. Then when there is a postback, the data source some how re-sorted itself and then the new data can be seen at the top .
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question