Solved

Gridview AllowPaging  refreshes data

Posted on 2011-03-10
5
597 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
  • 4
5 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

11 Experts available now in Live!

Get 1:1 Help Now