Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET - What is the difference of DataSourceID and DataSource?

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

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.

like image 425
dpp Avatar asked Aug 17 '11 04:08

dpp


People also ask

What is DataSource in ado net?

In ADO.NET, you use a Connection object to connect to a specific data source by supplying necessary authentication information in a connection string. The Connection object you use depends on the type of data source. Each . NET Framework data provider included with the . NET Framework has a DbConnection object: the .

What is data source control?

Data source controls present data in a consistent way to data-bound controls, regardless of the source or format of the underlying data. You use the data source controls that are provided with ASP.NET, including SqlDataSource, AccessDataSource, and XmlDataSource, to perform most Web development tasks.


1 Answers

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 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.

like image 81
VinayC Avatar answered Sep 16 '22 23:09

VinayC