1

I have a ListView control with DDL in its EditItemTemplate:

<asp:ListView ID="ListView1" ItemType="Project.Models.Product" 
              SelectMethod="GetProducts" runat="server" >
    <EditItemTemplate>
        <asp:DropDownList runat="server" ID="ProducerDDL" 
                          DataValueField="ProducerId" 
                          DataTextField="Name" 
                          SelectMethod="GetProducers" />
    </EditItemTemplate>
</asp:ListView>

Project.Models.Product contains property Producer. So the question is: how to set actual Producer of the edited Product item as the selected item of ProducerDDL?

Alex Skiba
  • 437
  • 2
  • 15

1 Answers1

2

So it seems the solution is just using Bind() the proper way:

<asp:DropDownList SelectedValue='<%# Bind("Producer.ProducerId") %>' />

as the binding context is my Product item.

Alex Skiba
  • 437
  • 2
  • 15