什么是对ASPX服务器端数据绑定控件的DataSource属性的最低要求? [英] What's the minimum requirement for the DataSource property of ASPX server side data-bound controls?

查看:132
本文介绍了什么是对ASPX服务器端数据绑定控件的DataSource属性的最低要求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图追溯,可分配给数据绑定ASP.NET控件的数据源属性数据源的最小类型的要求。

I'm trying to trace back the minimum type requirement of a data source that can be assigned to the DataSource property of data-bound ASP.NET controls.

我记得我在前面每有几个月或几年的差距之间的时间做了很多次。我认为,在同一时间,我追溯数据源是一个 IListSource ,但我可能是错的。或者可能是我混淆与WinForms的数据绑定控件的数据源财产的情况。

I remember that I did this many times earlier every time with a few months or years' gap in between. I think at one time, I traced back the DataSource to be an IListSource, but I could be wrong. Or may be I am confusing the situation with the DataSource property of WinForms data-bound controls.

不管怎样,我开始了一遍。在 System.Web.UI.WebControls.BaseDataList 类的<​​code>数据源属性,比如,被声明为对象

Anyway, I am starting all over again. The DataSource property of the System.Web.UI.WebControls.BaseDataList class, for instance, is declared as object.

我还期待着在DevEx preSS控制和DevEx preSS MVC扩展,从而真正从继承,然后委托数据绑定到ASP.NET服务器端控件类。他们还宣布了数据源属性为类型的对象,因为他们委托绑定到ASP.NET控件本身。

I am also looking at DevExpress controls and DevExpress MVC Extensions, which really inherit from and then delegate the data binding to ASP.NET server side control classes. They also declare the DataSource property to be of type object since they delegate the binding to the ASP.NET control itself.

即使在DevEx preSS扩展套件,的的数据源属性 DevEx press.Web.ASPxClasses.ASPxDataWebControlBase 类被声明为类型对象

Even in the DevExpress Extension suite, the DataSource property of the DevExpress.Web.ASPxClasses.ASPxDataWebControlBase class is declared to be of type object.

那么,什么是最起码的要求? 的IEnumerable&LT; T&GT; 我会想。或者甚至可能只是的IEnumerable (非通用的一种)。

So, what's the minimum requirement? IEnumerable<T> I'd think. Or may be even just IEnumerable (the non-generic one).

是否有谈到这个文档中的某个地方?

Is there some place in the documentation that talks about this?

推荐答案

不知道这是否可以帮助你或没有,但使用反射对你所提到的类显示对象被设置为财产必须是IListSource和IEnumerable数据源:

Not sure if this helps you or not, but using Reflector on the class you mentioned shows the object being set to the DataSource property needs to be IListSource and IEnumerable:

    set
    {
        if (((value != null) && !(value is IListSource)) && !(value is IEnumerable))
        {
            throw new ArgumentException(SR.GetString("Invalid_DataSource_Type", new object[] { this.ID }));
        }
        this.dataSource = value;
        this.OnDataPropertyChanged();
    }

这篇关于什么是对ASPX服务器端数据绑定控件的DataSource属性的最低要求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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