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. Advertisements

  2. Hello Ton
    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.
     
    Peter Bucher [MVP], Mar 11, 2008
    #2
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.