Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have one problem in the Gridview.

I have given Allowpaging is "True".

But, when i load the page it is always showing the second page only.

what is the problem...?

ASPX Page
---------
XML
<asp:GridView ID="GridView1" runat="server" align="center" AllowPaging="true"  
                                 AutoGenerateColumns="False" class="tab1" DataSourceID="SqlDataSource1" 
                                 HorizontalAlign="Center" Width="100%">



ASPX.VB Page
--------------
VB
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
       Dim sno As New Label
       Dim SrNo As Integer
       If e.Row.RowType = DataControlRowType.DataRow Then
           SrNo = (GridView1.PageIndex + 1) * 10 - 9
           sno = e.Row.FindControl("Sno")
           sno.Text = e.Row.RowIndex + SrNo
           sno.DataBind()
       End If
       'for Edit the PR Details to pass the PRNo and RevisionNo in the URL
       Dim Hyper1 As New HyperLink
       If e.Row.RowType = DataControlRowType.DataRow Then
           Hyper1 = e.Row.FindControl("hyperlink1")
           Dim PNo1 As Integer = e.Row.Cells(1).Text
           Dim RevNo1 As Integer = e.Row.Cells(3).Text
           Hyper1.NavigateUrl = "PR.aspx?PNo=" & e.Row.Cells(1).Text & "&RevNo=" & e.Row.Cells(3).Text & "&page=" & GridView1.PageIndex + 1
           Hyper1.DataBind()
       End If
   End Sub
Posted
Updated 27-Jul-11 6:07am
v3
Comments
Tajuddin_HYD 27-Jul-11 8:18am    
GridView1.PageIndex + 1
y r u taking +1 here?
thatraja 27-Jul-11 12:07pm    
Show the Page_load() code. Update that in your question.

1 solution

Do you mean there's more than 2 pages, or just 2 and you only see the second ? I agree with the guy who posted a comment, pageindex + 1 looks suspicious to me.
 
Share this answer
 
Comments
gani7787 27-Jul-11 9:01am    
I have more than 2 pages.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900