am using custom pagination

using the following

Case "Prev"
If GridView1.PageIndex > 0 Then
GridView1.PageIndex = Int32.Parse(GridView1.PageCount) - 1
End If


Case "Next"
If GridView1.PageIndex < (GridView1.PageCount - 1) Then


GridView1.PageIndex = Int32.Parse(GridView1.PageCount) + 1
End If

for first and last its wrking properly

but in using this two pagination is not proper
if i click on next the last page gets dispalyed and if clicked on pevious nothing happens no change

second thing is
i get some filtered data for gridview
suppose the filtered data has 2 pages on gridview , so when i click next it shld dispaly 2nd page instead its reset to the whole dataset records

how do i correct the things

Recommended Answers

All 2 Replies

Hi

Populate your dataset with appropriate data

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


      Dim sb1 As New StringBuilder
            Dim dsBranches As New DataSet


            sb1.Append(" SELECT")
            sb1.Append(" a.BranchName, a.CategoryID, b.categoryName,  Address,a.Street,a.PostBoxNo,a.CityID,")
            sb1.Append(" c.cityname, a.CountryID, d.countryname, a.Telephone, a.Email, a.WebAddress")
            sb1.Append(" from")
            sb1.Append(" companybranchinfo a, category b, city c,country d")
            sb1.Append(" where a.categoryid =b.categoryid and")
            sb1.Append(" a.cityid = c.cityid and")
            sb1.Append(" a.countryid = d.countryid")
            sb1.Append(" and a.CompanyId = " & intCoID)
            strQuery = ""
            strQuery = sb1.ToString
            '------------------------------
            dsBranches = objdata.LoadData(strQuery)
            If Not IsNothing(dsBranches) Then
                dvBranch.DataSource = dsBranches.Tables(0)
                dvBranch.DataBind()
            End If
        End If

 End Sub

 Protected Sub dvBranch_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewPageEventArgs) Handles dvBranch.PageIndexChanging
        dvBranch.PageIndex = e.NewPageIndex
        dvBranch.DataBind()
    End Sub

Mark as "solved" if it helps you

Regards

really cant trace the error
in page load if not postback i have populated & binded the grid
i get the total records both with filtration and without filtration
and also populated on postback

suppose i get total 50 pages without filtration and 10 page on filtering few records , on page load both works fine

without filteration , next/previous(post back works fine) but with filteration on post back it shows all 50 pages instead of going to the 2nd page of 10 pages

can naybody guide me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.