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

<!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 SqlDataSource</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <br />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id_compte"
            DataSourceID="SqlDataSource1">
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True"></asp:CommandField>
                <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" />
            </Columns>
        </asp:GridView>
        <br />
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:bancaConnectionString %>"
            SelectCommand="SELECT * FROM [compte]" DeleteCommand="DELETE FROM [compte] WHERE [id_compte] = @id_compte" InsertCommand="INSERT INTO [compte] ([titulaire], [solde]) VALUES (@titulaire, @solde)" UpdateCommand="UPDATE [compte] SET [titulaire] = @titulaire, [solde] = @solde WHERE [id_compte] = @id_compte">
            <DeleteParameters>
                <asp:Parameter Name="id_compte" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="titulaire" Type="String" />
                <asp:Parameter Name="solde" Type="Decimal" />
                <asp:Parameter Name="id_compte" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="titulaire" Type="String" />
                <asp:Parameter Name="solde" Type="Decimal" />
            </InsertParameters>
        </asp:SqlDataSource>    
        <br />
        <br />
    </div>
    </form>
</body>
</html>
