ASP.NET - How to use SelectParameters in SqlDataSource

SqlDataSource SelectParameters
SqlDataSourceParameter.aspx

<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Text" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    void GridView1_Selected(object sender, SqlDataSourceStatusEventArgs e)
    { 
        StringBuilder textBuilder = new StringBuilder();
        foreach(System.Data.SqlClient.SqlParameter param in e.Command.Parameters)
        {
            textBuilder.Append(Server.HtmlEncode(param.ParameterName)+": Value=");
            textBuilder.Append(Server.HtmlEncode(param.Value.ToString()) + " Type[");
            textBuilder.Append(Server.HtmlEncode(param.Value.GetType().ToString())+ "]");
            Label1.Text = textBuilder.ToString();
        }
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>How to use SelectParameters and asp:Parameter in SqlDataSource</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy; font-style:italic;">SqlDataSource Example: SelectParameters and asp:Parameter</h2>
        <asp:SqlDataSource 
            ID="SqlDataSource1"
            runat="server"
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            SelectCommand="GetProducts"
            SelectCommandType="StoredProcedure"
            OnSelected="GridView1_Selected"
            >
            <SelectParameters>
                <asp:Parameter Direction="ReturnValue" Name="ReturnParameter" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:Label 
            ID="Label1" 
            runat="server"
            Font-Bold="true"
            Font-Italic="true"
            Font-Size="Large"
            ForeColor="BurlyWood"
            Font-Names="Verdana"
            >
        </asp:Label>
        <br /><br />
        <asp:GridView 
            ID="GridView1"
            runat="server"
            DataSourceID="SqlDataSource1"
            AutoGenerateColumns="false"
            AllowPaging="true"
            Font-Names="Comic Sans MS"
            PageSize="9"
            BorderColor="Ivory"
            Width="650"
            >
            <RowStyle BackColor="Peru" ForeColor="Snow" Font-Italic="true" />
            <HeaderStyle BackColor="OrangeRed" ForeColor="Snow" Height="45"/>
            <PagerStyle 
                Height="45" 
                HorizontalAlign="Right" 
                BackColor="BurlyWood"
                Font-Bold="true"
                Font-Size="X-Large"
                ForeColor="Snow"
                />
            <PagerSettings Mode="Numeric" />
            <Columns>
                <asp:BoundField HeaderText="Product ID" DataField="ProductID" />
                <asp:BoundField HeaderText="ProductName" DataField="ProductName" />
                <asp:BoundField HeaderText="Quantity Per unit" DataField="QuantityPerUnit" />
                <asp:BoundField HeaderText="Unit Price" DataField="UnitPrice" />
            </Columns>
        </asp:GridView>
    </div>
    </form>
</body>
</html>
GetProducts [Stored Procedure]

CREATE PROCEDURE [dbo]. [GetProducts]
AS
SELECT ProductID, ProductName, QuantityPerUnit, UnitPrice FROM Products

DECLARE @Count smallint
SELECT @Count = Count(ProductID) FROM Products
RETURN @Count
More asp.net examples