datagrid paging - codebehind

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Re: datagrid paging - codebehind

    are you setting the button column to CommandName=Select in the ASP page?


    "Bent Kjeldsen" <news@nospam.dithjem.dk> wrote in message
    news:eYgAfqrRDHA.2148@TK2MSFTNGP11.phx.gbl...
    > Hi.
    > (Framework 1.1)
    > I'm trying to make paging on a datagrid, but my eventhandler for
    > PageIndexChanged is never called when I'm pressing Next, and an empty page
    > is shown. Below is a small CodeBehind example. I've also tried to put the
    > grid in the aspx page, but same result. Anyone?
    >
    > Thanks
    > Bent
    > Denmark
    >
    > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Init
    >
    > InitializeComponent()
    >
    > Grid = New System.Web.UI.WebControls.DataGrid
    >
    > oForm.Controls.Add(Grid)
    >
    > Grid.AllowPaging = True
    >
    > Grid.PagerStyle.Mode = PagerMode.NextPrev
    >
    > Grid.PageSize = 2
    >
    > End Sub
    >
    >
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    >
    > If Not Page.IsPostBack Then
    >
    > BindGrid()
    >
    > Else
    >
    > AddHandler Grid.PageIndexChanged, AddressOf Me.Page_Change
    >
    > End If
    >
    > End Sub
    >
    >
    >
    > Public Sub Page_Change(ByVal sender As System.Object, ByVal e As
    > System.Web.UI.WebControls.DataGridPageChangedEvent Args)
    >
    > Response.Write("Page_Change never called")
    >
    > Grid.CurrentPageIndex = e.NewPageIndex
    >
    > BindGrid()
    >
    > End Sub
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >

    Nimbus Dorkus Guest

  2. Similar Questions and Discussions

    1. DataGrid and Paging
      Hello Masters! Anyone can help me with the datagrid, well, the app load a lot of data from DB and it show on the datagrid, and well, I need to...
    2. datagrid codebehind formatting
      What if columns are not boundColumns? "Teemu Keiski" <joteke@aspalliance.com> escribió en el mensaje news:eQZRrOYDEHA.1604@TK2MSFTNGP11.phx.gbl...
    3. Datagrid SelectedIndexChanged Problem in CodeBehind
      I am attempting to use the SelectedIndexChanged to detect when a row has been selected. I have seen many examples where they are writing all the...
    4. First Datagrid row with paging
      Hi, My Datagrid header is a shoe size range and depends on the first datagrid row - first article size range. So, i need to get the first row...
    5. using Paging in Datagrid
      Hi, I am adding a paging function to a datagrid control, the datasource is a DataSet Object. Based on some articles, I just add some attributes to...
  3. #2

    Default Re: datagrid paging - codebehind

    I'm not quite sure what you mean ? :-)
    Is it mandatory? Can it be set codebehind?

    Thanks.

    Bent

    "Nimbus Dorkus" <spanz_za@hotmail.com> wrote in message
    news:eeRgYSsRDHA.1896@TK2MSFTNGP12.phx.gbl...
    > are you setting the button column to CommandName=Select in the ASP page?
    >
    >
    > "Bent Kjeldsen" <news@nospam.dithjem.dk> wrote in message
    > news:eYgAfqrRDHA.2148@TK2MSFTNGP11.phx.gbl...
    > > Hi.
    > > (Framework 1.1)
    > > I'm trying to make paging on a datagrid, but my eventhandler for
    > > PageIndexChanged is never called when I'm pressing Next, and an empty
    page
    > > is shown. Below is a small CodeBehind example. I've also tried to put
    the
    > > grid in the aspx page, but same result. Anyone?
    > >
    > > Thanks
    > > Bent
    > > Denmark
    > >
    > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles MyBase.Init
    > >
    > > InitializeComponent()
    > >
    > > Grid = New System.Web.UI.WebControls.DataGrid
    > >
    > > oForm.Controls.Add(Grid)
    > >
    > > Grid.AllowPaging = True
    > >
    > > Grid.PagerStyle.Mode = PagerMode.NextPrev
    > >
    > > Grid.PageSize = 2
    > >
    > > End Sub
    > >
    > >
    > >
    > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles MyBase.Load
    > >
    > > If Not Page.IsPostBack Then
    > >
    > > BindGrid()
    > >
    > > Else
    > >
    > > AddHandler Grid.PageIndexChanged, AddressOf Me.Page_Change
    > >
    > > End If
    > >
    > > End Sub
    > >
    > >
    > >
    > > Public Sub Page_Change(ByVal sender As System.Object, ByVal e As
    > > System.Web.UI.WebControls.DataGridPageChangedEvent Args)
    > >
    > > Response.Write("Page_Change never called")
    > >
    > > Grid.CurrentPageIndex = e.NewPageIndex
    > >
    > > BindGrid()
    > >
    > > End Sub
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    >
    >

    Bent Kjeldsen Guest

  4. #3

    Default Re: datagrid paging - codebehind

    Found the problem,

    Page.EnableViewState = True

    must be in Page_Init when disabled in Web.Config

    Thanks

    Bent



    "Nimbus Dorkus" <spanz_za@hotmail.com> wrote in message
    news:eeRgYSsRDHA.1896@TK2MSFTNGP12.phx.gbl...
    > are you setting the button column to CommandName=Select in the ASP page?
    >
    >
    > "Bent Kjeldsen" <news@nospam.dithjem.dk> wrote in message
    > news:eYgAfqrRDHA.2148@TK2MSFTNGP11.phx.gbl...
    > > Hi.
    > > (Framework 1.1)
    > > I'm trying to make paging on a datagrid, but my eventhandler for
    > > PageIndexChanged is never called when I'm pressing Next, and an empty
    page
    > > is shown. Below is a small CodeBehind example. I've also tried to put
    the
    > > grid in the aspx page, but same result. Anyone?
    > >
    > > Thanks
    > > Bent
    > > Denmark
    > >
    > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles MyBase.Init
    > >
    > > InitializeComponent()
    > >
    > > Grid = New System.Web.UI.WebControls.DataGrid
    > >
    > > oForm.Controls.Add(Grid)
    > >
    > > Grid.AllowPaging = True
    > >
    > > Grid.PagerStyle.Mode = PagerMode.NextPrev
    > >
    > > Grid.PageSize = 2
    > >
    > > End Sub
    > >
    > >
    > >
    > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles MyBase.Load
    > >
    > > If Not Page.IsPostBack Then
    > >
    > > BindGrid()
    > >
    > > Else
    > >
    > > AddHandler Grid.PageIndexChanged, AddressOf Me.Page_Change
    > >
    > > End If
    > >
    > > End Sub
    > >
    > >
    > >
    > > Public Sub Page_Change(ByVal sender As System.Object, ByVal e As
    > > System.Web.UI.WebControls.DataGridPageChangedEvent Args)
    > >
    > > Response.Write("Page_Change never called")
    > >
    > > Grid.CurrentPageIndex = e.NewPageIndex
    > >
    > > BindGrid()
    > >
    > > End Sub
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    >
    >

    Bent Kjeldsen Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139