ObjectDataSource和ITypedList的问题 [英] Problem with ObjectDataSource and ITypedList

查看:38
本文介绍了ObjectDataSource和ITypedList的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello group,

我有ObjectDataSource和ITypedList的问题。


在这个条目的末尾你找到我的List类的实现,

派生自ArrayList并实现ITypedList。列表中包含的所有项目都是类型为Person的类型,这是一个从无任何内容派生的类,

实现没有接口。

我放了一个我的表单上的DataSourceObject和Gridview。 DataSourceObject的

选择方法是GetAllPersons。


现在问题:运行表单时我看到有三列的网格

类Person的公共属性,以及列表中的项目。但我确实没有在设计时看到这个



感谢任何帮助。


问候

Norbert Ruessmann

[DataObject(true)]

公共类PersonsInArrayList:ArrayList,ITypedList

{

public PersonsInArrayList()

{

this.Add(new Person(1," James"," Cook"));

}

public ArrayList AllPersons()

{

返回此;

}


#region ITypedList会员


公共PropertyDescriptorCollection

GetItemProperties(PropertyDescriptor [] listAccessors)

{

PropertyDescriptorCollection propsColl

= TypeDescriptor.GetProperties(typeof(Person));

返回propsColl;

}


公共字符串GetListName(PropertyDescriptor [] listAccessors)

{

Debug.WriteLine(" PersonInArrrayList :: GetListName") ;

re转GrossElternCollection;

}


#endregion

}

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
}

推荐答案

您好Norbert,


您需要返回一个强类型列表,以使GridView能够在设计时显示

列列表时间。以下是最简单的DataObject:


[DataObject(true)]

公共类PersonsInArrayList

{

public IList< PersonAllPersons()

{

IList< Personlist = new List< Person>();

list.Add(new人(1,John,Cook));

返回列表;

}

}


我希望这会有所帮助。如果有任何不清楚的地方,请随时发布。


此致,

Walter Wang(wa****@online.microsoft.com,删除' '在线'。')

微软在线社区支持


==================== ==============================

通过电子邮件收到我的帖子通知?请参阅
http://msdn.microsoft .com / subscripti ... ult.aspx#notif

ications。如果您使用的是Outlook Express,请确保清除

复选框工具/选项/读取:一次获取300个标题及时看到你的回复




注意:MSDN托管新闻组支持服务是针对非紧急问题

其中来自社区或Microsoft支持的初步响应

工程师可在1个工作日内完成。请注意,每个跟随

的响应可能需要大约2个工作日作为支持

专业人士与您合作可能需要进一步调查才能达到

最有效的分辨率。该产品不适用于需要紧急,实时或基于电话的交互或复杂的b $ b项目分析和转储分析问题的情况。这种性质的问题最好通过联系

Microsoft客户支持服务(CSS)处理
href =http://msdn.microsoft.com/subscriptions/support/default.aspx\"target =_ blank> http://msdn.microsoft.com/subscripti...t/default.aspx

======================================== ==========


此帖子按原样提供。没有保证,也没有授予任何权利。

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.


谢谢你的答案,


我知道它是使用带有泛型的列表。我的问题是:在过去

(.NET 1.1)中我们开发了很多业务组件,可能是用于Windows Forms中数据绑定的
。可以将这些组件拖到窗体上,并使用像DataGrid这样的控件设计器来指定数据绑定。

可以指定数据绑定。这些组件也可以在

ASP.NET 1.1中使用---只需将它们拖到设计器的页面上并指定

数据绑定。


1.1中没有泛型,因此

组件使用的集合实现了IBindingList,ITypedList和

IListSource等接口。感谢ITypedList,.NET的绑定机制能够知道我们的集合项的属性。


在.NET 2.0中,这些组件在Windows中仍能正常运行表单 - 但不是在
ASP.NET中,因为ASP.NET 2.0中删除了这个很棒的功能。因此,我试图在我们的组件周围编写类似包装器的东西,以便能够将它们与ObjectDataSource一起使用。
。如果有必要,我甚至会编写自己的

数据源控件,但我不知道从哪里开始。


我更喜欢得到像ITypedList这样的东西。也许有一些界面我没有在文档中找到,它提供与Windows窗体for ASP.NET中的ITypedList相同的内容。


问候

Norbert Ruessmann

Walter Wang [MSFT]" < wa **** @ online.microsoft.comschrieb im Newsbeitrag

news:71 ************** @ TK2MSFTNGXA01.phx.gbl ...
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...

您好Norbert,


您需要返回一个强类型列表以启用GridView来显示
$ b设计时$ b列列表。以下是最简单的DataObject:


[DataObject(true)]

公共类PersonsInArrayList

{

public IList< PersonAllPersons()

{

IList< Personlist = new List< Person>();

list.Add(new人(1,John,Cook));

返回列表;

}

}


我希望这会有所帮助。如果有任何不清楚的地方,请随时发布。


此致,

Walter Wang(wa****@online.microsoft.com,删除' '在线'。')

微软在线社区支持


==================== ==============================

通过电子邮件收到我的帖子通知?请参阅
http://msdn.microsoft .com / subscripti ... ult.aspx#notif

ications。如果您使用的是Outlook Express,请确保清除

复选框工具/选项/读取:一次获取300个标题看到你的

回复

及时。


注意:MSDN管理新闻组支持服务是针对非紧急问题的/>
,可以在1个工作日内收到社区或Microsoft支持工程师的初步回复。请注意,每个跟随

的响应可能需要大约2个工作日作为支持

专业人士与您合作可能需要进一步调查才能达到

最有效的分辨率。该产品不适用于需要紧急,实时或基于电话的交互或复杂的b $ b项目分析和转储分析问题的情况。这种性质的问题最好通过联系

Microsoft客户支持服务(CSS)处理
href =http://msdn.microsoft.com/subscriptions/support/default.aspx\"target =_ blank> http://msdn.microsoft.com/subscripti...t/default.aspx

======================================== ==========


此帖子按原样提供。没有保证,并且不授予

权利。
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.



您好Norbert,

感谢您的澄清。


您能否向我发送在.NET 1.1中正常工作的代码

(WinForm和ASP。净)?我将尝试在.NET 2.0上验证它们,看看

为什么他们停止使用ASP.NET 2.0。


同时,我是目前正在我们的内部数据库中搜索关于ASP.NET 2.0中数据绑定更改的

相关文档。


感谢您的耐心和理解。


问候,

Walter Wang(wa****@online.microsoft.com,删除''在线''')

微软在线社区支持


================================== ================

在回复帖子时,请回复群组通过你的新闻阅读器

其他人可以从你的问题中学习并从中受益。

==================== ==============================

此帖子提供按现状 ;没有保证,也没有授予任何权利。

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.


这篇关于ObjectDataSource和ITypedList的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆