Bonjour,
Je souhaiterais savoir comment faire pour récupérer une dropdownlist dans mon code behind afin de réaliser un databinding, le tous en mode édition. voici mon code :
Ensuite dans mon code behind je pensais pouvoir récupérer ma dropdownlist ainsi:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 <EditItemTemplate> <asp:TextBox runat="server" ID="txt_nom_update" Text='<%# Bind("Nom") %>'></asp:TextBox><br/><br/> <asp:TextBox runat="server" ID="txt_description_update" Text='<%# Bind("Description") %>' TextMode="MultiLine"></asp:TextBox><br/><br/> <asp:TextBox runat="server" ID="txt_prix_update" Text='<%# Bind("Prix") %>'></asp:TextBox><br/><br/> <asp:DropDownList runat="server" ID="drp_categorie_update"></asp:DropDownList><br/><br/> <asp:DropDownList runat="server" ID="drp_pays_update"></asp:DropDownList><br/><br/> <asp:LinkButton runat="server" ID="link_update_button" CommandName="Update" Text="Mettre à jour"></asp:LinkButton> </EditItemTemplate>
Mais cela ne fonctionne pas. Vous auriez une idée ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 DropDownList drp = (DropDownList) ((ListView) sender).FindControl("drp_categorie_update"); drp.DataSource = Testproject.Services.Categorie.Categorie.ListeCategorie(); drp.DataTextField = "Nom"; drp.DataValueField = "ID"; drp.DataBind();
Partager