ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  ASP.NET Data Controls Part 3: DataList
Subject:   Implementing a DropDownList in Edit Mode in a DataList
Date:   2004-08-24 03:59:30
From:   bertieCbass
Response to: Implementing a DropDownList in Edit Mode in a DataList

In your HTML editItemTemplate add something like this for your listbox:
<td<asp:DropDownList id="DropDownList1" runat="server" SelectedIndex='<%# DataBinder.Eval(Container.DataItem, "existingDataValue") %>'> <asp:ListItem>0</asp:ListItem> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> </asp:DropDownList></td>


Note you need to set the SelectedIndex if you want to position the listbox to the existing data value


In the Update_Command code refer to the list like this:


DimdropList As DropDownList
dropList = CType(e.Item.FindControl("DropDownList1"), DropDownList)
intValue = dropList.SelectedItem.Value


Worked for me!