Groups | Blog | Home
all groups > asp.net building controls > march 2008 >

asp.net building controls : strange behaviour in gridview servercontrol with allowpaging = true


ton
3/5/2008 12:17:13 PM
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
Peter Bucher [MVP]
3/11/2008 7:50:28 PM
Hello Ton

[quoted text, click to view]
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
AddThis Social Bookmark Button