Salut à tous
Voilà, j'utilise un DetailView pour editer le profil de mes utilisateurs.
J'arrive à afficher leur profils, mais la modification ne se fait pas

Voilà un bout de code (dsl c un peu long)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
<asp:Label ID="Bienvenu" Text="Welcome" runat="server"/>
        <asp:HiddenField ID="UserId" runat="server"/>
            <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSourceProfil"
                Height="50px" Width="125px" AutoGenerateRows="False" OnItemCreated="DetailsView1_ItemCreated">
                <Fields>
                    <asp:BoundField DataField="Name" HeaderText="FistName" SortExpression="Name" />
                    <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
                    <asp:BoundField DataField="Adress" HeaderText="Address" SortExpression="Adress" />
                    <asp:BoundField DataField="Region" HeaderText="Region" SortExpression="Region" />
                    <asp:BoundField DataField="ZipCode" HeaderText="ZipCode" SortExpression="ZipCode" />
                    <asp:TemplateField HeaderText="Country" SortExpression="CountryName" Visible="False">
                        <InsertItemTemplate />
                        <ItemTemplate>
                            <asp:Label ID="LabelCountry" runat="server" Text='<%# Bind("CountryName") %>' />
                        </ItemTemplate>
                        <EditItemTemplate>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Country" SortExpression="CountryId" Visible="False">
                    <InsertItemTemplate />
                    <ItemTemplate>
 
                    </ItemTemplate>
                    <EditItemTemplate>
                            <asp:DropDownList ID="DropDownListCountry" runat="server" DataSourceID="SqlDataSourceCountry" DataTextField="CountryName" DataValueField="CountryId" SelectedValue='<%# Bind("CountryId") %>' AutoPostBack="true">
                            </asp:DropDownList>
                    </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
                    <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                    <asp:BoundField DataField="Birthday" HeaderText="Birthday" SortExpression="Birthday" />
                    <asp:TemplateField HeaderText="Photo" SortExpression="Photo">
                        <EditItemTemplate>
                            <asp:FileUpload ID="PictureUpload" runat="server" ></asp:FileUpload>
                        </EditItemTemplate>
                        <InsertItemTemplate>
 
                        </InsertItemTemplate>
                        <ItemTemplate>
                            <asp:Image ID="Photo" runat="server" ImageUrl='<%# Bind("Photo") %>'></asp:Image>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:CommandField ShowEditButton="True" />
                </Fields>
            </asp:DetailsView>
            <asp:SqlDataSource ID="SqlDataSourceProfil" runat="server" ConnectionString="<%$ ConnectionStrings:MyCNN %>"
                SelectCommand="SELECT Doctor.CountryId, Doctor.Name, Doctor.LastName, Doctor.Adress, Doctor.Region, Doctor.ZipCode, Country.CountryName, Doctor.Phone, Doctor.Email, Doctor.Birthday, Doctor.Photo FROM Doctor INNER JOIN Country ON Doctor.CountryId = Country.CountryId WHERE (Doctor.UserId = @UserId)" 
                UpdateCommand="UPDATE Doctor SET Name = @Name, LastName = @LastName, CountryId = @CountryId, Region = @Region, Adress = @Adress, ZipCode = @ZipCode, Phone = @Phone, Email = @Email, Birthday = @Birthday, Photo = @Photo WHERE (UserId = @UserId)">
                <SelectParameters>
                    <asp:ControlParameter ControlID="UserId" Name="UserId" PropertyName="Value" Type="String" />
                </SelectParameters>
                <UpdateParameters>
                    <asp:Parameter Name="Name" Type="String"/>
                    <asp:Parameter Name="LastName" Type="String"/>
                    <asp:Parameter Name="CountryId" />
                    <asp:Parameter Name="Region" Type="String"/>
                    <asp:Parameter Name="Adress" Type="String"/>
                    <asp:Parameter Name="ZipCode" Type="String"/>
                    <asp:Parameter Name="Phone" Type="String"/>
                    <asp:Parameter Name="Email" Type="String"/>
                    <asp:Parameter Name="Birthday" Type="DateTime"/>
                    <asp:Parameter Name="Photo" Type="String" />
                    <asp:Parameter Name="UserId" Type="String" />
                </UpdateParameters>
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="SqlDataSourceCountry" runat="server" ConnectionString="<%$ ConnectionStrings:MyCNN %>"
            SelectCommand="Select CountryId,CountryName FROM Country ORDER BY CountryName" ></asp:SqlDataSource>

Merci

PS: Le parametre UserId est obtenu a partir du HiddenField, je le rempli lors du chargement de la page.