Solved

Gridview AllowPaging  refreshes data

Posted on 2011-03-10
5
613 Views
Last Modified: 2012-06-27
Hi Experts,

How do I get a Gridview to refresh the data shown on the webpage,
as is done,
when a page is selected and  AllowPaging="True"?

I have used:
SqlDataSource1.DataBind();
GridView1.DataBind();

They DO NOT bring up the updated value from the underlying SQL table.
The only way I can get the new value is to exit and reenter the webpage or
toggle the Pages, throught the "AllowPaging".

I am reasking a question that was originally asked in:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_26872949.html
AllowPaging.JPG
0
Comment
Question by:AndyPandy
[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
  • 4
5 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 35093896
you need to refresh the data on paging ...right then add this

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)  
  {        GridView1.PageIndex = e.NewPageIndex;
       bindGridView();  
 }


binf data on page chage

for more infor refer
http://programming.top54u.com/post/ASP-Net-2-0-Gridview-Paging-using-C-sharp.aspx

0
 

Author Comment

by:AndyPandy
ID: 35094662
Hi Pratima,

Instead of rebuilding the connection from scratch.
(Which I am not sure I could convert my SQLdatasource to your hardcoded connection)
How would I disconnect the grid and datasource,  then reconnect them.
Thereby refreshing the CNT column on the grid.

Thanks
<asp:SqlDataSource ID="SqlDataSource1" runat="server" EnableCaching="false" ConnectionString="<%$ ConnectionStrings:CS1 %>"
        SelectCommand="SELECT [id], [term], [url], [cnt] FROM [gogetit] ORDER BY [createdate] DESC">
    </asp:SqlDataSource>

Open in new window

0
 

Author Comment

by:AndyPandy
ID: 35096406
Update:  I have simplified the code, and found that whenever I clcik a button or go to another page,  it stops any further display update of the CNT column.  
As long as I keep clicking the URL it will incremen the counter,  but as soon as I click a button or page then it stops the update of the CNT column.
0
 

Author Comment

by:AndyPandy
ID: 35098172
Update: Response.Redirect(url_temp,false); is causing the problem.
When commented out,  everthing works fine.
Why is this?
0
 

Author Closing Comment

by:AndyPandy
ID: 35103142
Not quite what I was looking for.
Turns out I need ato understand how/why of Response.Redirect(url_temp,false); changing the viewstate
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

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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