Solved

Gridview AllowPaging  refreshes data

Posted on 2011-03-10
5
605 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
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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 video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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