Calling a Stored Procedure using SqlDataSource in asp.net

Calling a Stored Procedure using SqlDataSource
Stored Procedure: GetProductDetailsByID

CREATE PROCEDURE [dbo].[GetProductDetailsByID]
@ProductID int
 AS
SELECT ProductID, ProductName, UnitPrice FROM  Products
WHERE ProductID=@ProductID
StoredProcedureExample.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>asp.net SqlDataSource example: SelectCommandType StoredProcedure</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Teal">SelectCommandType StoredProcedure</h2>
        <asp:SqlDataSource
             ID="SqlDataSource1"
             runat="server"
             ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
             SelectCommand="SELECT ProductID, ProductName FROM Products"
             SelectCommandType="Text"
             >
        </asp:SqlDataSource>
        <asp:DropDownList
             ID="DropDownList1"
             runat="server"
             DataSourceID="SqlDataSource1"
             DataTextField="ProductName"
             DataValueField="ProductID"
             AutoPostBack="true"
             BackColor="IndianRed"
             ForeColor="Snow"
             >
        </asp:DropDownList>
        <asp:SqlDataSource 
            ID="SqlDataSource2"
            runat="server"
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            DataSourceMode="DataReader"
            SelectCommand="GetProductDetailsByID"
            SelectCommandType="StoredProcedure"
            >
            <SelectParameters>
                <asp:ControlParameter Name="ProductID" ControlID="DropDownList1" PropertyName="SelectedValue" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br /><br />
        <asp:DetailsView 
            ID="DetailsView1"
            runat="server"
            DataSourceID="SqlDataSource2"
            BackColor="CornflowerBlue"
            ForeColor="AliceBlue"
            >
        </asp:DetailsView>
    </div>
    </form>
</body>
</html>
More asp.net examples