I have the following code to create a gridview with pages listed at bottom
However, when I click on the different pages, nothing happens(it looked like it reloaded the same page), but when I open in a new tab in Chrome, it just opens a blank page, when I hover over the link "2" to go to page 2, this is what shows:
I see nothing in your code that could be causing your problem. What happens if you remove
OnPageIndexChanging="GridView1_PageIndexChanging" and
don't call that routine? It seems that something unseen is going on. Try stepping through your code in debug, line by line.
I think the problem might be related to MVC not supporting GridView paging due to no support to HTTP POST backs.
I am running Win7, doesn't work in IE/FireFox/Chrome. And Nothing happens when I take out OnPageIndexChanging. It isn't being called regardless.
So I can't step through the aspx code from VS2010.
zergy
0 Points
3 Posts
ASP.NET 4.0 MVC3 GridView paging using SqlDataSource not working
Feb 27, 2013 04:09 PM|LINK
I have the following code to create a gridview with pages listed at bottom
However, when I click on the different pages, nothing happens(it looked like it reloaded the same page), but when I open in a new tab in Chrome, it just opens a blank page, when I hover over the link "2" to go to page 2, this is what shows:
javascript:__doPostBack('ctl00$MainContent$GridView1','Page$2')
Code:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.master" Inherits="..." %> <script runat="server"> protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind(); } </script><asp:GridView ID="GridView1" runat="server" AllowPaging="True" OnPageIndexChanging = "GridView1_PageIndexChanging" AutoGenerateColumns="False" DataKeyNames="LastName,FirstName" EnablePersistedSelection="True" SelectedRowStyle-BackColor="Yellow" DataSourceID="SqlDataSource1" AllowSorting="True" > <Columns> <asp:BoundField DataField="LastName" HeaderText="Last Name" ReadOnly="True" SortExpression="LastName" /> <asp:BoundField DataField="FirstName" HeaderText="First Name" ReadOnly="True" SortExpression="FirstName" /> ... </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" SelectCommand="SELECT * FROM User WHERE [IsDeleted]=0"></asp:SqlDataSource>Nothing seems to work, the "GridView1_PageIndexChanging" function isn't even being called when I click on other pages
Am I missing something somewhere? Any help appreciated!
paindaasp
Star
12080 Points
2034 Posts
Re: ASP.NET 4.0 MVC3 GridView paging using SqlDataSource not working
Feb 27, 2013 06:18 PM|LINK
I see nothing in your code that could be causing your problem. What happens if you remove OnPageIndexChanging = "GridView1_PageIndexChanging" and don't call that routine? It seems that something unseen is going on. Try stepping through your code in debug, line by line.
ddgiovanni1
Member
2 Points
10 Posts
Re: ASP.NET 4.0 MVC3 GridView paging using SqlDataSource not working
Feb 27, 2013 06:27 PM|LINK
What does it do in IE? What operating system are you using?
zergy
0 Points
3 Posts
Re: ASP.NET 4.0 MVC3 GridView paging using SqlDataSource not working
Feb 27, 2013 08:22 PM|LINK
I think the problem might be related to MVC not supporting GridView paging due to no support to HTTP POST backs.
I am running Win7, doesn't work in IE/FireFox/Chrome. And Nothing happens when I take out OnPageIndexChanging. It isn't being called regardless.
So I can't step through the aspx code from VS2010.