View Single Post
  #8 (permalink)  
Old December 1st, 2005, 04:48 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I don't see why this wouldn't work. This works for me:
Code:
<asp:TemplateField HeaderText="Description" SortExpression="Description">
  <EditItemTemplate>
    <asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("Description") %>'>
      <asp:ListItem>Posters</asp:ListItem>
      <asp:ListItem>Mugs</asp:ListItem>
      <asp:ListItem>Mugs</asp:ListItem>
      </asp:DropDownList>
    </EditItemTemplate>
    When I set the DefaultMode to edit, it displays the first record in my resultset and preselects the right item. You need *no* code behind to do this.

Could it be that your page is messed up by trying? What happens when you create a new page, add a single DataSource and a DetailsView, change 1 field in the DetailsView to a TemplateField and add a drop down to it? Then set DefaultMode of the DetailsView to Edit.

That should work. If it doesn't can you post the code?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote