Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 18-03-2009
Member
 
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
Reply With Quote
  #2  
Old 18-03-2009
Member
 
Join Date: May 2008
Posts: 2,293
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.
Reply With Quote
  #3  
Old 18-03-2009
Member
 
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
Reply With Quote
  #4  
Old 18-03-2009
Member
 
Join Date: May 2008
Posts: 2,293
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;
Reply With Quote
  #5  
Old 18-03-2009
Member
 
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
Reply With Quote
  #6  
Old 18-03-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
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>
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to select dropdownlist default selected"
Thread Thread Starter Forum Replies Last Post
Hotmail on Nokia E72, Cannot select default access point Roakman Portable Devices 5 09-01-2011 08:34 AM
Asus laptop:Reboot & select proper boot device or insert boot media in selected boot device? animalkindness Windows XP Support 1 24-05-2010 04:59 PM
Not able to select default download folder Ernesto4 Technology & Internet 5 05-01-2010 12:57 AM
Help to update the DropDownList HiSpeed Software Development 2 23-04-2009 11:37 PM
Reboot and select proper boot device or insert boot media in selected boot device cobra2008 Hardware Peripherals 5 31-01-2009 01:13 PM


All times are GMT +5.5. The time now is 09:21 AM.