asp.net.ph

Skip Navigation Links

SqlDataSource Control Syntax

ASP.NET Syntax   ASP.NET Syntax for Web Controls


Enables declarative data-binding to objects from a SQL Server™ database.

Declarative Syntax

For information on the individual members of this class, see SqlDataSource in the class library.

Remarks

The SqlDataSource control represents data in a Microsoft SQL Server™ database to data-bound controls. The SqlDataSource control is used in conjunction with a data-bound control to display the data on a Web Forms page, and optionally allow users to update the data, with little or no code.

Syntax Example

The following example demonstrates how to declaratively use a SqlDataSource control to retrieve data from Microsoft SQL Server™ and display it in a GridView control.

<asp:gridview id="CustomersGridView" runat="server"
   datasourceid="customers"
   width=80% cellpadding=5
   font-size = "9pt">

   <headerstyle backcolor = "steelblue"
      forecolor = "beige" />

   <rowstyle verticalalign = "top" />

</asp:gridview>

<asp:sqldatasource id="customers" runat="server"
   selectcommand = "SELECT CustomerID, CompanyName, Address, City, PostalCode, Country " +
      " FROM Customers"
   connectionstring = "<%$ ConnectionStrings:aspnet %>"
   datasourcemode = "DataReader" />

 Show me 

See Also

SqlDataSource Class   SqlDataSource Web Server Control



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note