473,785 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET 2 > ObjectDataSourc e 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 objectdatasourc e (ODS) beacause
filters and sort are automaticly managed....

I would like that my own gridview (inherited from
system.web.ui.w ebcontrols.grid view) 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.W ebControls.Grid View

Private WithEvents _ods As ObjectDatasourc e

Public ReadOnly Property odsDataSource() As ObjectDatasourc e
Get
If _ods Is Nothing Then
_ods = New ObjectDatasourc e
_ods.ID = "_ods"
_ods.EnableView State = False
End If
Return _ods
End Get
End Property

Protected Overrides Sub OnLoad(ByVal e As System.EventArg s)
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_Thi ngList
Inherits System.Web.UI.U serControl

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
'GV is my gridView in the ThingList control
GV.odsDataSourc e.TypeName = "my_type"
GV.odsDataSourc e.SelectMethod = "function_name_ for_data_source "
End Sub

End Class



Aug 31 '06 #1
1 2176
syl
Hi!

Problem solve!

in fact, I cant do a gridview.contro ls.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 objectdatasourc e (ODS) beacause
filters and sort are automaticly managed....

I would like that my own gridview (inherited from
system.web.ui.w ebcontrols.grid view) 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.W ebControls.Grid View

Private WithEvents _ods As ObjectDatasourc e

Public ReadOnly Property odsDataSource() As ObjectDatasourc e
Get
If _ods Is Nothing Then
_ods = New ObjectDatasourc e
_ods.ID = "_ods"
_ods.EnableView State = False
End If
Return _ods
End Get
End Property

Protected Overrides Sub OnLoad(ByVal e As System.EventArg s)
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_Thi ngList
Inherits System.Web.UI.U serControl

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
'GV is my gridView in the ThingList control
GV.odsDataSourc e.TypeName = "my_type"
GV.odsDataSourc e.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
1990
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 parameter. When the Update-method is invoked by the ObjectDataSource, the object referenced is not the same object returned by the Select-method, but a new object with only the values from the Edit-template. So basically I get a reference to a useless...
4
8507
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 reading): <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" DataKeyNames="Id" OnRowUpdated="GridView1_RowUpdated">
0
1497
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 connect to my business logic everything works fine. The problem is that I find this quite limited and I need to do some custom work with the parameters, so I am trying to code everything by hand in the code behind. >From a security perspective,...
2
3826
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 DataKeyNames parameter of "UserCompany, BillableCompany". The DetailsView has control parameters for its select method pointing to these two keys on the GridView. But the select method function receives two copies of the UserCompany field! The...
0
1892
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 paging. The objectdatasource SelectMethod returns a dataview. When my objectdatasource is declared in the codebehind, sorting is not working and i receive following error when clicking on a datagrid's column header. I made the same test...
5
2657
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 simply working with objects in memory. So, it appears as though Microsoft requires that our datamapper classes reside inside a folder called "App_Code", and NO WHERE ELSE. So, has anyone successfully been able to place their datamappers in a...
4
20906
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: myGridView.DataBind(); does not work! There is no clear method for the ODS. How do I get rid of it?
0
5522
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 code what I think is a fairly typical Master/Detail scenario with two GridViews, using AJAX. Using the Northwind sample, I have two ObjectDataSources - one which pulls data from the Orders table, and one that pulls the related data from . Each...
5
2176
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 always 0 and not the ID of the selected record (which is the case when updating) How come?
0
9484
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10350
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10097
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9957
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5518
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.