Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Gridview AllowPaging  refreshes data

Posted on 2011-03-10
5
Medium Priority
?
633 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Integration Management Part 2

926 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