strange behaviour in gridview servercontrol with allowpaging = true

Discussion in 'ASP .Net Building Controls' started by ton, Mar 5, 2008.

  1. ton

    ton Guest

    Hi,
    This is a part of my custum server control. The DataTbl in de sub is a
    recordset (ADODOTNET). It works fine when Allowpaging is not set, but when I
    set is to True I receive an error: Nullreference exception was unhandled by
    user code

    Protected Overrides Sub CreateChildControls()
    Grid = New GridView
    Grid.ID = "Grid"
    Grid.AutoGenerateColumns = True
    Grid.AllowPaging = True
    Grid.DataSource =DataTbl 'a correct datatable
    Grid.DataBind() 'ERROR OCCURS on this line: Nullreference exception
    was unhandled by user code
    Controls.Add(Grid)
    End Sub

    thanks


    ton
    ton, Mar 5, 2008
    #1
    1. Advertising

  2. Hello Ton

    > This is a part of my custum server control. The DataTbl in de sub is a
    > recordset (ADODOTNET). It works fine when Allowpaging is not set, but when
    > I set is to True I receive an error: Nullreference exception was unhandled
    > by user code

    If you allow Paging, you`ve to handle the pageindexchanged event.
    It could be that problem, try to wire up the event manually and restart.

    --
    Gruss, Peter Bucher
    Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
    http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
    http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET
    Peter Bucher [MVP], Mar 11, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon
    Replies:
    1
    Views:
    366
    Ken Cox [Microsoft MVP]
    Mar 3, 2004
  2. Jonathan Wood

    GridView Blank with AllowPaging="True"

    Jonathan Wood, Jan 29, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    618
    Jonathan Wood
    Jan 29, 2007
  3. bdb112
    Replies:
    45
    Views:
    1,341
    jazbees
    Apr 29, 2009
  4. Jim Mitchell

    How to find a record in a Datagrid with AllowPaging set to true.

    Jim Mitchell, Jul 26, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    179
    Jim Mitchell
    Jul 26, 2003
  5. Atanas Marinov

    Problem creating custom header when datagrid AllowPaging=true

    Atanas Marinov, May 28, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    255
    Atanas Marinov
    May 29, 2004
Loading...

Share This Page