Groups | Blog | Home
all groups > vb.net data > august 2006 >

vb.net data : .NET 2 > GridView/ObectDataSource


syl
8/31/2006 9:12:55 PM
Hello

I am trying to create a "easy to use" gridview with filters (dropdownlist in
headers), sorting...and much more....
In order to do that, i prefer to use a objectdatasource (ODS) beacause
filters and sort are automaticly managed....

I would like that my own gridview (inherited from
system.web.ui.webcontrols.gridview) includes a ODS which I expose by
properties. In that way, I use this "advanced" grid view without adding on
each page the ODS......

well.....my problem is that I cant add a ODS in my gridview....
in the gridview, in the onload or OnPreRender method, I try to affect the
datasourceid property to the ID of the "inside" ODS...but i get always the
same error :
<<<the DataSourceID of "mygridview" must be the ID of a IDataSource control.
A control with the ID "_ods" was noty found>>>

Am I missing something?
Do you have a idea?

Thanks a lot!!!

Bye
Syl

PS :
My code looks like that :

-------------my grid view-------------------------
Public Class GridView
Inherits Common.Web.UI.WebControls.GridView

Private WithEvents _ods As ObjectDatasource

Public ReadOnly Property odsDataSource() As ObjectDatasource
Get
If _ods Is Nothing Then
_ods = New ObjectDatasource
_ods.ID = "_ods"
_ods.EnableViewState = False
End If
Return _ods
End Get
End Property

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
Me.Controls.Add(_ods)
Me.DataSourceID = _ods.ID
End Sub

.....a lot of things with OnRowCreated, OnPreRender, and much
more.....!!!....

End Class


---------------use of my grid view in a webcontrol-------------------

Partial Class webControls_ThingList
Inherits System.Web.UI.UserControl

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
'GV is my gridView in the ThingList control
GV.odsDataSource.TypeName = "my_type"
GV.odsDataSource.SelectMethod = "function_name_for_data_source"
End Sub

End Class





syl
9/1/2006 12:00:00 AM
Hi!

Problem solve!

in fact, I cant do a gridview.controls.add(ODS)
I must add the ODS in the parent control (ASPX or ASCX)


bye!
syl


"syl" <lobrys_NOSPAM@free.fr> a écrit dans le message de news:
uhZtJFTzGHA.4232@TK2MSFTNGP04.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button