ASP.NET - 是什么的DataSourceID和DataSource的区别? [英] ASP.NET - What is the difference of DataSourceID and DataSource?

查看:587
本文介绍了ASP.NET - 是什么的DataSourceID和DataSource的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是什么的DataSourceID和DataSource从控件的属性有什么区别?我可以使用它们互换?

What is the difference of DataSourceID and DataSource from the controls' attribute? Can I use them interchangeably?

当我尝试设置数据源酒店在设计时,由aspx页面上键入它,我得到,说:在'数据源'属性不能例外设置声明。但是当我使用属性窗口更改数据源,它给人也不例外。

When I try to set DataSource property at the design time, by typing it on the aspx page, I get an exception that says "The 'DataSource' property cannot be set declaratively.". But when I use property window to change the DataSource, it gives no exception.

推荐答案

数据源是指可以提供.NET数据源控件(如ObjectDataSource的实际数据源对象,SqlDataSource的)或实际数据对象,如数据表,对象等的集合

DataSource refers to actual data source object which can be .NET provided data source controls (such as ObjectDataSource, SqlDataSource) or actual data objects such as DataTable, Collection of objects etc.

的DataSourceID 是.NET中的字符串标识符提供的数据源控件,并且此属性的存在使得数据绑定控件和相应的数据源可以在设计时在关联标记。在内部,控制看起来为使用提供的ID实际的数据源控件。

DataSourceID is the string identifier for .NET provided data source control and this property exists so that data-bound control and corresponding data source can be associated at the design time in markup. Internally, the control would look up for actual data source control using the id provided.

这篇关于ASP.NET - 是什么的DataSourceID和DataSource的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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