Bonjour à tous,

J'ai une DropDownList avec une liste de code, à la sélection d'un de ces codes je fais une vérification dans ma base SQL pour afficher des informations dans un Label et une Textbox.

Je souhaite pouvoir modifier ma Textbox et pouvoir enregistré cette nouvelle valeur dans ma base SQL.

Sauf que, quand je clique sur mon bouton "Enregistrer", ca ne prend pas ma nouvelle valeur de ma Textbox !!??

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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
 
<script runat="server">  
 
    // Chargement de la page.
    protected void OnLoad(EventArgs e)
    {
    }
 
    // Affiche le détail de l'ordinateur selectionné.
    private void Switch_Change(Object sender, EventArgs e)
    {
        Label_Switch_Detail.Text = " ";
        Txt_Switch_Name.Text = "";
 
        //Recherche du code dans la base "inventaire" pour afficher le détail du switch
        System.Data.DataView dvSql = (System.Data.DataView)Sql_Switch_Details.Select(DataSourceSelectArguments.Empty);
        foreach (System.Data.DataRowView drvSql in dvSql)
        {
            Label_Switch_Detail.Text = drvSql["Code_constructeur"].ToString()
                                        + " , " + drvSql["Code_modèle"].ToString()
                                        + " , " + drvSql["Code_série"].ToString(); 
        }
 
        //Recherche du code dans la base "switch" pour afficher la configuration du switch
        System.Data.DataView dvSql2 = (System.Data.DataView)Sql_test_switch.Select(DataSourceSelectArguments.Empty);
        foreach (System.Data.DataRowView drvSql2 in dvSql2)
        {
            Txt_Switch_Name.Text = drvSql2["nom_Switch"].ToString();
        }
    }
 
    private void Switch_Save_Click(Object sender, EventArgs e)
    {
        //Recherche du code dans la base "switch" 
            System.Data.DataView dvSql3 = (System.Data.DataView)Sql_test_switch.Select(DataSourceSelectArguments.Empty);
            if (dvSql3.Count == 0) //si le switch n'existe, on l'Insert
            {
               Sql_Switch_Save.Insert();
            }
            else //si le switch existe, on l'Update
            {
               Sql_Switch_Save.Update();
            }
 
            //recréation de la liste DDl_Switch
            DDl_Switch.Items.Clear();
            DDl_Switch.DataSource = Sql_Switch;
            DDl_Switch.DataSourceID = "";
            DDl_Switch.Items.Add(new ListItem("--------------------", "0"));
            DDl_Switch.DataBind();
            DDl_Switch.SelectedIndex = 0;
 
        }
 
</script>  
 
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server" />
 
 
<table>
    <tr>
        <td width="380" valign="top"><!--#include file="MenuNetwork.inc" --></td>
        <td valign="top" >
 
        <form id="form1" name="form1" method="post">
            <fieldset>
            <div class="detail_mouvement">
                <div class="titre_detail_mouvement"> Configuration de switch </div>
                <asp:Label ID="Label_date" Visible="false" runat="server"></asp:Label>
 
            <table>
              <tr>
                <td colspan="4">        
                    <ol class="round">
                        <li class="one">
                            <h5>Selectionner du switch</h5>
                        </li>
                    </ol>
                </td>
              </tr>
 
              <tr>
                <td width="50">&nbsp;</td>
                <td width="150">
                    <asp:DropDownList 
                        ID="DDl_Switch" 
                        runat="server" 
                        AutoPostBack="True"
                        Width="130px" 
                        OnSelectedIndexChanged="Switch_Change"
                        AppendDataBoundItems="True" 
                        ViewStateMode="Disabled" DataSourceID="Sql_Switch" DataTextField="Code_Inv" DataValueField="Code_Inv">
                        <asp:ListItem Selected="True" Value="0">--------------------</asp:ListItem>
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="Sql_Switch" 
                        runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
                        SelectCommand="SELECT * FROM [Inventaire] WHERE ([type] = @type)">
                        <SelectParameters>
                            <asp:Parameter DefaultValue="SWITCH" Name="type" Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
                <td width="10">&nbsp;</td>
                <td width="350">
                    <asp:Label ID="Label_Switch_Detail" runat="server" Text="" ></asp:Label>
 
                    <asp:SqlDataSource ID="Sql_Switch_Details" 
                        runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
                        SelectCommand="SELECT * FROM [Inventaire] WHERE ([Code_Inv] = @Code_Inv)">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="DDl_Switch" Name="Code_Inv" PropertyName="SelectedValue" Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>
 
                    <asp:SqlDataSource ID="Sql_test_switch" 
                        runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
                        SelectCommand="SELECT * FROM [Switch] WHERE ([Code_Inv] = @Code_Inv)">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="DDl_Switch" Name="Code_Inv" PropertyName="SelectedValue" Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>
              </tr>
 
              <tr>
                <td colspan="4">
                    <ol class="round">
                        <li class="two">
                            <h5>configuration</h5>
                        </li>
                    </ol>
                </td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>
                    Nom du switch :</td>
                <td>&nbsp;</td>
                <td> 
                    <asp:TextBox ID="Txt_Switch_Name" Font-Size="Small" runat="server"></asp:TextBox>
                </td>
              </tr>
             </table>
 
            </div>
 
            <div class="float-right-padding">
                <p>
                    <asp:Button ID="install_save" OnClick="Switch_Save_Click" runat="server" Text="Enregistrer" /> 
                </p>
            </div>
            <div class="float-right-padding">
            </div>  
                    <asp:Label ID="Label_switch_save" CssClass="message-success" runat="server" Text=""></asp:Label>
 
                <asp:SqlDataSource ID="Sql_Switch_Save" 
                    runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"  
                    InsertCommand="INSERT INTO [Switch] ([Code_Inv], [Nom_Switch]) VALUES (@Code_Inv, @Nom_Switch)" 
                    UpdateCommand="UPDATE [Switch] SET [Nom_Switch] = @Nom_Switch WHERE [Code_Inv] = @Code_Inv" >
                    <InsertParameters>
                        <asp:ControlParameter Name="Code" ControlId="DDl_Switch"              PropertyName="SelectedValue" />
                        <asp:ControlParameter Name="Nom_Switch"    ControlId="Txt_Switch_Name"         PropertyName="Text" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:ControlParameter Name="Code" ControlId="DDl_Switch"              PropertyName="SelectedValue" />
                        <asp:ControlParameter Name="Nom_Switch"    ControlId="Txt_Switch_Name"         PropertyName="Text" />
                    </UpdateParameters>
                </asp:SqlDataSource>
 
            </fieldset>
        </form>
        </td>
    </tr>
</table>
 
</asp:Content>
Auriez-vous une idée ??

Merci d'avance