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

<!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>Liste des comptes</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            DataKeyNames="id_compte" DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" PageSize="3">
            <Columns>
                <asp:HyperLinkField DataNavigateUrlFields="id_compte" DataNavigateUrlFormatString="operations.aspx?id_compte={0}"
                    DataTextField="titulaire" DataTextFormatString="Operations de {0}" />
                <asp:BoundField DataField="titulaire" HeaderText="Titulaire" SortExpression="titulaire" />
                <asp:BoundField DataField="solde" DataFormatString="{0:c}" HeaderText="Solde" HtmlEncode="False" />
                <asp:TemplateField HeaderText="Agence" SortExpression="NOM_AGENCE">
                    <EditItemTemplate>
                        &nbsp;<asp:DropDownList ID="DropDownList1" runat="server">
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("NOM_AGENCE") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:Label ID="lbl_info" runat="server"></asp:Label><br />
        <br />
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:bancaConnectionString %>"
            DeleteCommand="DELETE FROM [compte] WHERE [id_compte] = @id_compte" InsertCommand="INSERT INTO [compte] ([titulaire], [solde], [id_agence]) VALUES (@titulaire, @solde, @id_agence)"
            SelectCommand="SELECT COMPTE.ID_COMPTE, COMPTE.TITULAIRE, COMPTE.SOLDE, COMPTE.ID_AGENCE, AGENCE.NOM_AGENCE FROM COMPTE INNER JOIN AGENCE ON COMPTE.ID_AGENCE = AGENCE.ID_AGENCE" UpdateCommand="UPDATE [compte] SET [titulaire] = @titulaire, [solde] = @solde, [id_agence] = @id_agence 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_agence" Type="Int32" />
                <asp:Parameter Name="id_compte" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="titulaire" Type="String" />
                <asp:Parameter Name="solde" Type="Decimal" />
                <asp:Parameter Name="id_agence" Type="Int32" />
            </InsertParameters>
        </asp:SqlDataSource>
        &nbsp;</div>
    </form>
</body>
</html>
