<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test_sql_ds_param1.aspx.cs" Inherits="test_sql_ds_param1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Test 1 - paramètre DataSource</title>
</head>
<body>
    <form id="form1" runat="server">    
    <table>
    <tr>
    <td valign="top"><!-- liste combo -->
        <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="ds_liste"
            DataTextField="titulaire" DataValueField="id_compte" AutoPostBack="True">
        </asp:DropDownList><br /></td>
    <td><!-- affichage enregistrement par enregistrement -->
        <asp:DetailsView ID="dv" runat="server" AutoGenerateRows="False" DataKeyNames="id_compte"
            DataSourceID="ds_detail" Height="50px" Width="125px">
            <Fields>
                <asp:BoundField DataField="id_compte" HeaderText="id_compte" InsertVisible="False"
                    ReadOnly="True" SortExpression="id_compte" />
                <asp:BoundField DataField="titulaire" HeaderText="titulaire" SortExpression="titulaire" />
                <asp:BoundField DataField="solde" HeaderText="solde" SortExpression="solde" />
            </Fields>
        </asp:DetailsView></td>
    </tr>
    </table>        
        
        
        <!-- source alimentant la liste combo -->
        <asp:SqlDataSource ID="ds_liste" runat="server" 
        ConnectionString="<%$ ConnectionStrings:bancaConnectionString %>"
        SelectCommand="SELECT * FROM [compte]">
        </asp:SqlDataSource>
                
        
        
        <!-- source paramétrée -->
        <asp:SqlDataSource ID="ds_detail" runat="server" 
        ConnectionString="<%$ ConnectionStrings:bancaConnectionString %>"
        SelectCommand="SELECT * FROM [compte] WHERE ([id_compte] = @id_compte)">
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownList1" Name="id_compte" PropertyName="SelectedValue"
                Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>   
    </form>
</body>
</html>
