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.
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 .
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With