Solved

Gridview inside UpdaePanel does not update

Posted on 2010-08-30
6
415 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
  • 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now