473,401 Members | 2,146 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,401 software developers and data experts.

Problem with ObjectDataSource and ITypedList

Hello group,
I have a problem with ObjectDataSource and ITypedList.

At the end of this entry you find the implementatiopn of my List class,
derived from ArrayList and implementing ITypedList. All items contained in
the list are of type Person, which is a class derived from nothing and
implementing no Interfaces.
I put a DataSourceObject on my form and a Gridview. The DataSourceObject's
select method is GetAllPersons.

Now the problem: when running the form I see the grid with three columns for
the public properties of class Person, and the items of the list. But I do
not see this at design time.

Any help is appreciated.

Regards
Norbert Ruessmann
[DataObject(true)]
public class PersonsInArrayList : ArrayList , ITypedList
{
public PersonsInArrayList()
{
this.Add (new Person( 1 , "James" , "Cook" ));
}
public ArrayList AllPersons()
{
return this;
}

#region ITypedList Members

public PropertyDescriptorCollection
GetItemProperties(PropertyDescriptor[] listAccessors)
{
PropertyDescriptorCollection propsColl
=TypeDescriptor.GetProperties(typeof(Person));
return propsColl;
}

public string GetListName(PropertyDescriptor[] listAccessors)
{
Debug.WriteLine("PersonInArrrayList :: GetListName");
return "GrossElternCollection";
}

#endregion
}
Sep 12 '06 #1
11 1913
Hi Norbert,

You need to return a strong typed list to enable GridView to show the
column list at design time. Following is a simplest DataObject:

[DataObject(true)]
public class PersonsInArrayList
{
public IList<PersonAllPersons()
{
IList<Personlist = new List<Person>();
list.Add(new Person(1, "John", "Cook"));
return list;
}
}

I hope this helps. Please feel free to post here if anything is unclear.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 13 '06 #2
Thank you for the answer,

I know it is working using a list with generics. My problem is: in the past
(.NET 1.1) we developed quite a lot of business components which could be
used for data binding in Windows Forms. These components could be dragged
onto a Form, and using the designer of controls like DataGrid it was
possible to specify the data binding. These components could be used in
ASP.NET 1.1 as well --- just drag them on a page in designer and specify the
data bindings.

There were no generics in 1.1, therefore the collections used by the
components implemented interfaces like IBindingList, ITypedList and
IListSource. Thanks to ITypedList the binding mechanism of .NET was able to
know the properties of our collection items.

In NET 2.0 these components still work fine in Windows Forms -- but not in
ASP.NET since this great feature was removed in ASP.NET 2.0. Therefore I am
trying to write something like a wrapper around our components to be able
to use them with ObjectDataSource. If necessary I will even write my own
datasource control, but I do not know where to start.

I prefer to get something like ITypedList. Maybe there is some interface I
did not find in the documentation which provides the same as ITypedList in
Windows Forms for ASP.NET.

Regards
Norbert Ruessmann
"Walter Wang [MSFT]" <wa****@online.microsoft.comschrieb im Newsbeitrag
news:71**************@TK2MSFTNGXA01.phx.gbl...
Hi Norbert,

You need to return a strong typed list to enable GridView to show the
column list at design time. Following is a simplest DataObject:

[DataObject(true)]
public class PersonsInArrayList
{
public IList<PersonAllPersons()
{
IList<Personlist = new List<Person>();
list.Add(new Person(1, "John", "Cook"));
return list;
}
}

I hope this helps. Please feel free to post here if anything is unclear.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Sep 13 '06 #3
Hi Norbert,

Thanks for clarification.

Would you please sending me the code that is working correctly in .NET 1.1
(both WinForm and ASP.NET)? I will try to verify them on .NET 2.0 to see
why they stopped working on ASP.NET 2.0.

In the meanwhile, I'm currently searching in our internal database for
related documentation about the databinding changes in ASP.NET 2.0.

Thank you for your patience and understanding.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 13 '06 #4
Hi Walter,

making some sample code will take some time, because I have to extract it
from our projects. But there are some posts on the web explaining exactly
which feature has been removed in ASP.NET 2.0.

Here are some links:
http://clariusconsulting.net/blogs/k...omponents.aspx
http://connect.microsoft.com/VisualS...dbackID=102242
http://www.nikhilk.net/NonVisualCont...omponents.aspx
In my last post I forgot to mention that our collections derived from
IBindingList, ITypedList etc. are inside a component. This component can be
dragged onto a windows form, and in APS.NET 1.1. it was possible to use it
as well.

I understand that MS removed this feature in ASP.NET 2.0, which I have to
accept . Maybe MS will introduce t again in the future, but I need a
solution quite soon.

One solution for me is that I change the collections we use to generics
(List<myType>), which seems to be quite some work. My hope with theses
postings here is, that maybe somebody knows how the ASP.NET 2 designer finds
out about the item Types in a collection during design time. The designer
will use reflection, but is the designer only able to find out about the
item Types for IList<myType>, ore are ther other possibilities? Ideal would
be an interface I have to implement.

Regards
Norbert Ruessmann
"Walter Wang [MSFT]" <wa****@online.microsoft.comschrieb im Newsbeitrag
news:6R**************@TK2MSFTNGXA01.phx.gbl...
Hi Norbert,

Thanks for clarification.

Would you please sending me the code that is working correctly in .NET 1.1
(both WinForm and ASP.NET)? I will try to verify them on .NET 2.0 to see
why they stopped working on ASP.NET 2.0.

In the meanwhile, I'm currently searching in our internal database for
related documentation about the databinding changes in ASP.NET 2.0.

Thank you for your patience and understanding.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Sep 14 '06 #5
Hi Norbert,

Thank you for telling us detailed background of this issue. I fully
understand your concerns about the ASP.NET 2.0 changes on the component
support.

The GridView's designer code calls into the data source's designer to get
the list of columns and their types, as well as some other metadata. Use
ObjectDataSource for example, it's ObjectDataSourceDesigner that provides
that data. It uses reflection to get information about the return type of
your select method. It directly handles typed DataSets, DataTables,
IEnumerable<T>, and typed Arrays. Unfortunately it doesn't handle
ITypedList.

I'm afraid the most appropriate way here is to derive from List<Person>.

Please reply here to let us know whether or not you need further
information. Thank you.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 15 '06 #6
Hi Walter,

Thank you for the answer. In the meantime I found out how to solve my
problem --- write my own DataSourceControl including my own DataSourecView
and my own DataSourceDesigner. Thus I have full control which type
information I provide to controls like gridview.

Unfortunately there isn't too much documentation about this subject.
Especially I do not understand how to implemet RefreshSchema() in the class
derived form DataSourceDesigner. Do you have any idea where I can find it?

Apart from this lack of understanding I am optimistic that I can solve my
problem now.

Regards
Nobert Ruessmann
"Walter Wang [MSFT]" <wa****@online.microsoft.comschrieb im Newsbeitrag
news:DR*************@TK2MSFTNGXA01.phx.gbl...
Hi Norbert,

Thank you for telling us detailed background of this issue. I fully
understand your concerns about the ASP.NET 2.0 changes on the component
support.

The GridView's designer code calls into the data source's designer to get
the list of columns and their types, as well as some other metadata. Use
ObjectDataSource for example, it's ObjectDataSourceDesigner that provides
that data. It uses reflection to get information about the return type of
your select method. It directly handles typed DataSets, DataTables,
IEnumerable<T>, and typed Arrays. Unfortunately it doesn't handle
ITypedList.

I'm afraid the most appropriate way here is to derive from List<Person>.

Please reply here to let us know whether or not you need further
information. Thank you.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Sep 15 '06 #7
Norbert,

Take a look at this:

http://www.manuelabadia.com/blog/Per...ccad54357.aspx

and maybe you're interested in some of the posts here:

http://www.manuelabadia.com/blog/Per...977b8f00c.aspx

I hope it helps.

Manuel Abadia
http://www.manuelabadia.com

Norbert Ruessmann ha escrito:
Hi Walter,

Thank you for the answer. In the meantime I found out how to solve my
problem --- write my own DataSourceControl including my own DataSourecView
and my own DataSourceDesigner. Thus I have full control which type
information I provide to controls like gridview.

Unfortunately there isn't too much documentation about this subject.
Especially I do not understand how to implemet RefreshSchema() in the class
derived form DataSourceDesigner. Do you have any idea where I can find it?

Apart from this lack of understanding I am optimistic that I can solve my
problem now.

Regards
Nobert Ruessmann
"Walter Wang [MSFT]" <wa****@online.microsoft.comschrieb im Newsbeitrag
news:DR*************@TK2MSFTNGXA01.phx.gbl...
Hi Norbert,

Thank you for telling us detailed background of this issue. I fully
understand your concerns about the ASP.NET 2.0 changes on the component
support.

The GridView's designer code calls into the data source's designer to get
the list of columns and their types, as well as some other metadata. Use
ObjectDataSource for example, it's ObjectDataSourceDesigner that provides
that data. It uses reflection to get information about the return type of
your select method. It directly handles typed DataSets, DataTables,
IEnumerable<T>, and typed Arrays. Unfortunately it doesn't handle
ITypedList.

I'm afraid the most appropriate way here is to derive from List<Person>.

Please reply here to let us know whether or not you need further
information. Thank you.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.
Sep 15 '06 #8
Thanks Manuel,
this is the best information I found so far.

Regards
Norbert Rüßmann

"Manu" <ma******@gmail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Norbert,

Take a look at this:

http://www.manuelabadia.com/blog/Per...ccad54357.aspx

and maybe you're interested in some of the posts here:

http://www.manuelabadia.com/blog/Per...977b8f00c.aspx

I hope it helps.

Manuel Abadia
http://www.manuelabadia.com

Norbert Ruessmann ha escrito:
>Hi Walter,

Thank you for the answer. In the meantime I found out how to solve my
problem --- write my own DataSourceControl including my own
DataSourecView
and my own DataSourceDesigner. Thus I have full control which type
information I provide to controls like gridview.

Unfortunately there isn't too much documentation about this subject.
Especially I do not understand how to implemet RefreshSchema() in the
class
derived form DataSourceDesigner. Do you have any idea where I can find
it?

Apart from this lack of understanding I am optimistic that I can solve my
problem now.

Regards
Nobert Ruessmann
"Walter Wang [MSFT]" <wa****@online.microsoft.comschrieb im Newsbeitrag
news:DR*************@TK2MSFTNGXA01.phx.gbl...
Hi Norbert,

Thank you for telling us detailed background of this issue. I fully
understand your concerns about the ASP.NET 2.0 changes on the component
support.

The GridView's designer code calls into the data source's designer to
get
the list of columns and their types, as well as some other metadata.
Use
ObjectDataSource for example, it's ObjectDataSourceDesigner that
provides
that data. It uses reflection to get information about the return type
of
your select method. It directly handles typed DataSets, DataTables,
IEnumerable<T>, and typed Arrays. Unfortunately it doesn't handle
ITypedList.

I'm afraid the most appropriate way here is to derive from
List<Person>.

Please reply here to let us know whether or not you need further
information. Thank you.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader
so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.
Sep 15 '06 #9
Hi Norbert,

I agree creating a customized Data Source control is a promising to achieve
your requirement. Please feel free to let me know if you need anything else
on this topic.

Another resource on buiding Data Source controls is:

#ScottGu's Blog : Building your own Data Source Controls in ASP.NET 2.0
http://weblogs.asp.net/scottgu/archi...04/432319.aspx

I hope you could share your knowledge when you solved this issue; it surely
can benefit the whole community.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 18 '06 #10
Hello Group,

basically I have my own DataSourceControl working, using the components we
developed for Windows Forms. Now I have a little problem again.

Our components can have many collections. A simple case is similar to a one
to many relation in the database. As an example take a list of orders, where
each Order has a collection of OrderItems.

If I want to display Orders and OrderItems in two GridView controls, where
the one for Orders is selectable, I have to drop two of my DataSource
controls onto the form as well, one for handling the collection of Orders,
the other one for the collection of OrderItems. No problem so far, there is
an article explaining how to do this
(http://asp.net/learn/dataaccess/tuto...aspx?tabid=63).

My problem is this: in my DataSourceControl's Select method I do not want to
select the data from the database each time and create my business objects
from the data selected, but I want to select the data once. Actually our
Components have a Fill() method, which reads all data from the database
according to some rules. These data are automatically held by our component.

Now my question: I will have one instance of my component, but two
DataSource Controls (or even more in more complex scenarios). What is the
best way to handle this?
Regards
Norbert Ruessmann

"Walter Wang [MSFT]" <wa****@online.microsoft.comschrieb im Newsbeitrag
news:cV*************@TK2MSFTNGXA01.phx.gbl...
Hi Norbert,

I agree creating a customized Data Source control is a promising to
achieve
your requirement. Please feel free to let me know if you need anything
else
on this topic.

Another resource on buiding Data Source controls is:

#ScottGu's Blog : Building your own Data Source Controls in ASP.NET 2.0
http://weblogs.asp.net/scottgu/archi...04/432319.aspx

I hope you could share your knowledge when you solved this issue; it
surely
can benefit the whole community.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Sep 20 '06 #11
Hi Norbert,

Based on my understanding, your current situation is:

You have one business component (which is inherited from ArrayList) and two
or more DataSource controls associated to one instance of this component.
The component is getting data from database and returns business objects
accordingly. You want the component queries database only once in one
postback for all the associated DataSource controls.

Please correct me if I've misunderstood anything.

Two associate one instance of your business component to multiple
DataSource control, your DataSource control must not use reflection to
create its own instance (like ObjectDataSource did). You need to add a
property to your DataSource controls and assign the instance of your
business component to them at runtime.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 22 '06 #12

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

Similar topics

1
by: Joe Jax | last post by:
I'm building my own version of a readonly DataTable, which needs to bind to various controls. My data table class has two main collections (CollectionBase instances): one of columns, one of rows,...
0
by: Herman verschooten | last post by:
Hi, I am creating my first real ASP.NET 2.0 site and want to use the some of the new features. I created a masterpage with my main layout and added several contentpages, no problem so far. I...
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
2
by: J055 | last post by:
Hi I've implemented caching for my ObjectDataSource. <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" EnableCaching="True" CacheDuration="10" CacheExpirationPolicy="Sliding" ...
3
by: Tina | last post by:
I'm trying to do something very straightforward in a 2.0 asp.net app with a GridView - ObjectDataSource - DataSet. I create a DataSet that accesses the NorthWind Customers Table - all columns...
1
by: Prasanta | last post by:
Hello, I have a project less solution asp.net 2.0 with c#. I have a method in page code behind which returns a datatable, that method I want to assign in the objectdatasource select method, but...
0
by: fig000 | last post by:
Hi, I'm using an objectdatasource. The insert procedure called by the objectdatasource is in a separate library file outside of the aspx and the codebehind that is using the objectdatasource in...
0
by: Jeff | last post by:
hi there ;) asp.net 2.0 I'm having problem with paging in GridView, I'm using custom paging. The ObjectDataSource reads in the rows needed for displaying each page as each page is selected....
2
by: jojojulian | last post by:
I am having exactly the same problem Mr. Fischer reported below. Except in my case the page loads without any problem when run from my computer (localhost). Any suggestion would be appreciated....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...
0
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,...

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.