[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

strange behaviour in gridview servercontrol with allowpaging = true

ton

3/5/2008 11:17:00 AM

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

1 Answer

Peter Bucher [MVP]

3/11/2008 6:50:00 PM

0

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.aspn... - ASP.NET Zone, die ASP.NET Community
http://www.aspn...blogs/peterbucher/ - Auf den Spuren von .NET