Assembly: System.Web (in system.web.dll)
/** @property */ public String get_DataSourceID () /** @property */ public void set_DataSourceID (String value)
public function get DataSourceID () : String public function set DataSourceID (value : String)
Property ValueThe ID of a control that represents the data source from which the data-bound control retrieves its data. The default is String.Empty.
If the data-bound control has already been initialized (the ConfirmInitState method is called or OnPagePreLoad event is handled) when you set the DataSourceID property, the OnDataPropertyChanged method is called, which sets the RequiresDataBinding property to true.
The following code example demonstrates how the DataSourceID property of a data-bound control is used. The GridView control is associated to the SqlDataSource control by setting its DataSourceID property to "AuthorsSqlDataSource", the ID of the SqlDataSource control. When the DataSourceID property is set (instead of the DataSource property), the data-bound control automatically binds to the data source control at run time.
<%@ Page language="C#" %> <html> <body> <form runat="server"> <h3>GridView Example</h3> <asp:gridview id="CustomersGridView" datasourceid="CustomersSource" autogeneratecolumns="true" emptydatatext="No data available." allowpaging="true" runat="server"> </asp:gridview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="CustomersSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.