?
Solved

Gridview inside UpdaePanel does not update

Posted on 2010-08-30
6
Medium Priority
?
425 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 2000 total points
ID: 33562495
do u have any other update panel as parents to that update panel?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

777 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