473,378 Members | 1,347 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

.NET 2 > ObjectDataSource in GridView

syl
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



Aug 31 '06 #1
1 2155
syl
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" <lo***********@free.fra écrit dans le message de news:
uk**************@TK2MSFTNGP02.phx.gbl...
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



Sep 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ole M | last post by:
I'm having some trouble using the ObjectDataSource in ASP.NET 2.0. I have a wrapper that contains the static methods for Select and Update. The Update-method takes the business object as...
4
by: Anne Catterick | last post by:
Hi, I have an british ASP.Net 2.0 application which is doing what (should) be very simple. But I am having issues. On my page I have a GridView as follows (some tags excluded for easy...
0
by: Eiriken | last post by:
Hello everyone, I am using ASP.NET 2 and trying to bind a objectdatasource to a gridview. By doing this the most common way by adding an objectdatasource to the page and by using the wizard to...
2
by: Damon | last post by:
Help! Need this fixed ASAP. I have a GridView/DetailsView master/details form set up, with both bound to separate ObjectDataSource objects. Both the GridView and the DetailsView have a...
0
by: Northern | last post by:
Hello, I have some trouble to declare and instantiate dynamically an ObjectDataSource in the codebehind file. The idea is to bind the objectdatasource to a gridview and have automate sorting and...
5
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are...
4
by: GaryDean | last post by:
I have an objectdatasource reading a dataset and I have a gridview using that objectdatasource (at design time). It binds fine but I need to clear it. myGridView.DataSource = null:...
0
by: Phillip Ian | last post by:
Tried this over in CSharp.General and didn't get anything, so I thought I'd try again here. If there's an AJAX specific group I could ask this in, please let me know...I did look. I'm trying to...
5
by: cmrchs | last post by:
Hi, I'm trying out Databinding to a Data Acces Layer using a ObjectDataSource-control The Update works fine but the Delete-method doesn't. when debugging I see that my productID-parameter is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.