PageIndexChanging in Gridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shek124
    New Member
    • Oct 2007
    • 50

    PageIndexChanging in Gridview

    In my form, the gridview is bind , according to my selectedvalue in dropdownlist


    How can do paging in gridview using the pageindexchangi ng event for this condition.. please hwlp me
  • ShahbazAshraf
    New Member
    • Mar 2008
    • 36

    #2
    write this code in PageIndexChangi ng event

    {
    _gridView.PageI ndex = e.NewPageIndex; // Set the Page Index
    // then call the Search() method which will b your custom event for the searching of data on basis of dropdown list selection.
    }

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Originally posted by shek124
      In my form, the gridview is bind , according to my selectedvalue in dropdownlist


      How can do paging in gridview using the pageindexchangi ng event for this condition.. please hwlp me
      You are going to have to have the DropDownList autopostback to the server. Then you need to write the event handler for the SelectedIndexCh anged for the DropDownList. In that Method you need to set the GridView's Page Index, then rebind the data source to the GridView...


      Eg:
      [code=vbnet]
      Protected Sub MyDropDownList_ SelectedIndexCh anged(ByVal sender As Object, ByVal e As System.EventArg s) Handles MyDropDownList. SelectedIndexCh anged
      MyGridView.Page Index = Integer.Parse(M yDropDownList.S electedValue)
      MyGridView.Data Source = m_datasource
      MyGridView.Data Bind()
      End Sub
      [/code]

      -Frinny

      Comment

      Working...