DropDownList inside GridView: How to set SelectedIndex for the DropDownList?

Discussion in 'ASP .Net' started by keithb, May 1, 2006.

  1. keithb

    keithb Guest

    With a DropDownList in a GridView Edit Template, how can I set the
    SelectedIndex property so that the list initializes to the value shown in
    the Display template? When I set SelectedIndex to -1, the DropDownList
    initializes to the first entry.
    <asp:DropDownList ID="DropDownList2"

    runat="server"

    Width="75px"

    DataSource='<%# ReleasesAccess.GetReleases() %>'

    DataValueField = '<%# "RelID" %>'

    DataTextField = '<%# "ShortName" %>'

    SelectedIndex= '<%# -1 %>' >

    </asp:DropDownList>

    Thanks,

    Keith
    keithb, May 1, 2006
    #1
    1. Advertising

  2. keithb

    shauns1

    Joined:
    Nov 1, 2006
    Messages:
    1
    shauns1, Nov 1, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer
    Replies:
    1
    Views:
    18,555
    Cliff Harris
    Apr 7, 2004
  2. Replies:
    1
    Views:
    856
  3. S_K
    Replies:
    5
    Views:
    766
    Eliyahu Goldin
    Nov 14, 2007
  4. set dropdownlist selectedindex in datagrid

    , Feb 25, 2007, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    918
  5. Meagan

    DropDownList SelectedIndex won't set

    Meagan, Oct 29, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    200
    Meagan
    Oct 29, 2005
Loading...

Share This Page