Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Gridview AllowPaging  refreshes data

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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/…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

730 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