Bonjour à tous,
Cela fait 2 jours que je bloque sur le sujet et il me semble avoir le net entier
J'ai une DropDownListACModel que je voudrais updater en fonction du choix d'une DropDownListACType.
Voilà ma page ascx:
Et voilà le code behind en C#
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 <table class="AdjustTable"> <tbody> <tr> <td> <asp:DropDownList ID="DropDownListACType" style="width:50px; font-size:11px;" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownListACType_SelectedIndexChanged"> </asp:DropDownList> <asp:RequiredFieldValidator ID="RequiredFieldValidatorDropDownListACType" ControlToValidate="DropDownListACType" runat="server"/> </td> <td> - </td> <Triggers> <asp:AsyncPostBackTrigger ControlID="DropDownListACType" EventName="SelectedIndexChanged" /> </Triggers> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <td> <asp:DropDownList ID="DropDownListACModel" style="width:142px; font-size:11px;" runat="server" > </asp:DropDownList> <asp:RequiredFieldValidator ID="RequiredFieldValidatorDropDownListACModel" ControlToValidate="DropDownListACModel" runat="server"/> </td> </ContentTemplate> </asp:UpdatePanel> </tr> </tbody> </table>
et mon Page_Load
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 protected void DropDownListACType_SelectedIndexChanged(object sender, EventArgs e) { try { using (SPWeb currentWeb = SPContext.Current.Web.ParentWeb.ParentWeb) { SPList list = currentWeb.Lists["ACModelList"]; if (list != null) { string acType = DropDownListACType.SelectedValue; if (acType.CompareTo("") == 0) { DropDownListACModel.ClearSelection(); DropDownListACModel.Items.Clear(); DropDownListACModel.SelectedIndex = 0; } else if (acType.CompareTo("42") == 0) { DropDownListACModel.ClearSelection(); DropDownListACModel.Items.Clear(); foreach (SPListItem item in list.Items) { DropDownListACModel.Items.Add(item["ACType42"].ToString()); } DropDownListACModel.SelectedIndex = 0; } else if (acType.CompareTo("72") == 0) { DropDownListACModel.ClearSelection(); DropDownListACModel.Items.Clear(); foreach (SPListItem item in list.Items) { DropDownListACModel.Items.Add(item["ACType72"].ToString()); } DropDownListACModel.SelectedIndex = 0; } } } } catch (Exception ex) { PortalLog.LogString("Fill Drop Down List Ac Model error : " + ex.Message); } }
Le pb que j'ai c'est qu'il ya un postback sur la page entière et non seulement sur la DropDownListACModel du coup je perds les informations de ma balise input lors du postback.
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 protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { // Create User Service UsersService us = new UsersService(); USERS currUser = getCurrentUser(us); TextBoxStartDate.Enabled = false; TextBoxDeliveryDate.Enabled = false; // Fill the MRO Name with user entity name fillMROName(currUser, us); fillDropDownListACType(); fillReportingDate(); } }
Une idée ? Merci de votre aide.
Partager