Details View DropDownlist in edit mode

Last post 02-18-2007 4:08 PM by fullyii. 2 replies.

Sort Posts:

  • Details View DropDownlist in edit mode

    02-18-2007, 2:50 PM
    • Loading...
    • fullyii
    • Joined on 10-07-2005, 10:51 AM
    • Chicago, IL
    • Posts 83

    I created a deatailsview and in edit mode I want to replace the edit mode textbox with a dropdownlist.

    I did the following so far: 

    1. I converted the field into a TemplateField and deleted the textbox 
    2. I addedd a dropdownlist with two static values y and n

    What do I need to do to get the dropdownlist select value to edit the field like the texbox does?

     

    1    <EditItemTemplate>
    2    
    3                         
    4    
    5                        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" Style="position: relative; left: 0px;">
    6    
    7                            <asp:ListItem Value="Y">Yes</asp:ListItem>
    8    
    9                            <asp:ListItem Value="N">No</asp:ListItem>
    10   
    11                       </asp:DropDownList>
    12   
    13                   </EditItemTemplate>
    14   
    15                   <InsertItemTemplate>
    16   
    17                       <asp:DropDownList ID="DropDownList2" runat="server" Style="position: relative" AutoPostBack="True">
    18   
    19                           <asp:ListItem Selected="True">Yes</asp:ListItem>
    20   
    21                           <asp:ListItem>No</asp:ListItem>
    22   
    23                       </asp:DropDownList>
    24   
    25                   </InsertItemTemplate>
    26   
    27                   <ItemTemplate>
    28   
    29                       <asp:Label ID="Label1" runat="server" Text='
    Fullyii
  • Re: Details View DropDownlist in edit mode

    02-18-2007, 3:20 PM
    Answer
    • Loading...
    • michielvoo
    • Joined on 02-11-2007, 2:52 PM
    • Rotterdam
    • Posts 166

    Hello,

    you can use a binding expression for this. You want to bind the value of the selected value to a datasource:

    <asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("Field") %>'>

    The attribute SelectedValue is not listed by IntelliSense for a DropDownList, but it will bind against the property anyway.

    Good luck!
     

    When you have asked a question, remember to click "Mark as answered" for a reply that answered your question. This ensures the right forum member gets credits (and it makes search more relevant too).
    Filed under: ,
  • Re: Details View DropDownlist in edit mode

    02-18-2007, 4:08 PM
    • Loading...
    • fullyii
    • Joined on 10-07-2005, 10:51 AM
    • Chicago, IL
    • Posts 83
    That worked.  I cant believe how easy that was Thanks!
    Fullyii
Page 1 of 1 (3 items)
Microsoft Communities
Page view counter