Results 1 to 6 of 6

Thread: How to select dropdownlist default selected

  1. #1
    Join Date
    Nov 2008
    Posts
    21

    How to select dropdownlist default selected

    Hi friends,

    I want to edit page and like to display the default value in a
    dropdown list from the database.

    I am using the dropdownlist inside a repeater and only want to retriving single
    record at a time based on a querystring and using a datareader to fill the
    form.

    Intel Dual core 2.66 Ghz
    915 MSI Motherboard with Intel chipset
    512 mb RAM
    80gb HDD

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: How to select dropdownlist default selected

    Sure i will help you out with this before that may i know in which programming language you want to have the code.

  3. #3
    Join Date
    Nov 2008
    Posts
    21

    Re: How to select dropdownlist default selected

    I am using Asp.net

    Intel Dual core 2.66 Ghz
    915 MSI Motherboard with Intel chipset
    512 mb RAM
    80gb HDD

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: How to select dropdownlist default selected

    Try to use the ID of the CascadingDropDown set the SelectedValue property.

    For example:

    CascadingDropDown1.SelectedValue = id from level 1;

    CascadingDropDown2.SelectedValue = id from level 2;

  5. #5
    Join Date
    Nov 2008
    Posts
    21

    Re: How to select dropdownlist default selected

    I try to do it but it didn't worked out for me other solution please.

    Intel Dual core 2.66 Ghz
    915 MSI Motherboard with Intel chipset
    512 mb RAM
    80gb HDD

  6. #6
    Join Date
    Feb 2008
    Posts
    1,852

    Re: How to select dropdownlist default selected

    Try to use this code i am sure it will work for you.

    HTML Code:
    <%@ Page Language=”C#” %>
    
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
    
      “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
    
    <script runat=”server”>
    
     
    
        protected void DropDownListUser_DataBound(object sender, EventArgs e)
    
        {
    
            DropDownListUser.SelectedIndex =
    
              DropDownListUser.Items.IndexOf
    
              (DropDownListUser.Items.FindByValue(Context.User.Identity.Name));
    
        }
    
    </script>
    
     
    
    <html xmlns=”http://www.w3.org/1999/xhtml” >
    
    <head runat=”server”>
    
        <title>DropDownList Initialize</title>
    
    </head>
    
    <body>
    
        <form id=”form1″ runat=”server”>
    
        <div>
    
            <asp:DropDownList ID=”DropDownListUser” runat=”server”
    
              DataSourceID=”ObjectDataSourceUser”
    
              DataTextField=”UserName” DataValueField=”UserName”
    
              OnDataBound=”DropDownListUser_DataBound”>
    
            </asp:DropDownList>
    
            <asp:ObjectDataSource ID=”ObjectDataSourceUser” runat=”server”
    
              SelectMethod=”GetMembers”
    
              TypeName=”MembershipUtilities.MembershipUserODS”>
    
                <SelectParameters>
    
                    <asp:Parameter Name=”sortData” Type=”String” />
    
                </SelectParameters>
    
            </asp:ObjectDataSource>
    
        </div>
    
        </form>
    
    </body>
    
    </html>

Similar Threads

  1. Hotmail on Nokia E72, Cannot select default access point
    By Roakman in forum Portable Devices
    Replies: 5
    Last Post: 09-01-2011, 08:34 AM
  2. Replies: 1
    Last Post: 24-05-2010, 04:59 PM
  3. Not able to select default download folder
    By Ernesto4 in forum Technology & Internet
    Replies: 5
    Last Post: 05-01-2010, 12:57 AM
  4. Help to update the DropDownList
    By HiSpeed in forum Software Development
    Replies: 2
    Last Post: 23-04-2009, 11:37 PM
  5. Replies: 5
    Last Post: 31-01-2009, 01:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,642,685,390.34289 seconds with 17 queries