4 Replies - 3446 Views - Last Post: 30 June 2013 - 11:38 PM Rate Topic: -----

#1 786_student  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 29-June 13

The GridView 'GridView1' fired event PageIndexChanging wasn

Posted 30 June 2013 - 12:40 PM

Hi..

I am using a gridview and I want to use paging. I have already set allow paging to true and page size to 10. I can see the numbers at the base of my gridview, but when I click on a number to move to respective page, it throws an error saying:

The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.

Thank You!
Is This A Good Question/Topic? 0
  • +

Replies To: The GridView 'GridView1' fired event PageIndexChanging wasn

#2 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: The GridView 'GridView1' fired event PageIndexChanging wasn

Posted 30 June 2013 - 01:29 PM

View Post786_student, on 30 June 2013 - 01:40 PM, said:

I am using a gridview and I want to use paging. I have already set allow paging to true and page size to 10. I can see the numbers at the base of my gridview, but when I click on a number to move to respective page, it throws an error saying:

The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.

Have you made a PageIndexChanging event handler?
Was This Post Helpful? 0
  • +
  • -

#3 786_student  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 29-June 13

Re: The GridView 'GridView1' fired event PageIndexChanging wasn

Posted 30 June 2013 - 02:02 PM

Below is my code..but i don't know what to write inside this :

Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.SelectedIndexChanged

End Sub

Thanks!

Imports System.Data.OleDb

Partial Public Class employee
    Inherits System.Web.UI.Page
    Protected con As OleDbConnection



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

        Try


            Dim str As String
            con = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\sal1.mdb")
            str = "select *  from employee order by Sno"
            Dim da As OleDbDataAdapter
            Dim dset As New Data.DataSet
            da = New OleDbDataAdapter(str, con)
            da.Fill(dset, "employee")
            GridView1.DataSource = dset.Tables("employee")
            GridView1.DataBind()
            
            con.Close()
        Catch ex As Exception
            Response.Write("<script>alert('Try Again...!!'); window.location.href='employee.aspx'</script>")

        End Try

    End Sub

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.SelectedIndexChanged
      
    End Sub



   
End Class


Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3746
  • View blog
  • Posts: 13,116
  • Joined: 12-December 12

Re: The GridView 'GridView1' fired event PageIndexChanging wasn

Posted 30 June 2013 - 03:50 PM

The error message says specifically that it is looking for the event PageIndexChanging to be handled, not SelectedIndexChanged.
Was This Post Helpful? 0
  • +
  • -

#5 786_student  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 29-June 13

Re: The GridView 'GridView1' fired event PageIndexChanging wasn

Posted 30 June 2013 - 11:38 PM

Hi!
We have added the following and it is working also but we need to press the index two times to go to the required page.
Thanks!

  Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)Handles GridView1.PageIndexChanging

    GridView1.PageIndex = e.NewPageIndex

End Sub

 


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1