Click here to Skip to main content
12,249,797 members (53,625 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET

how to display selected values from dropdown list in textbox in asp.net
Posted 26-Oct-12 1:31am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

This is one of the basics. If you know DropDownList you must know how to do it. I guess you are new to asp.net serving you the answer.

TextBox1.Text =  Convert.Tostring(DropdownList1.SelectedItem.Value);
 
TextBox1.Text =  Convert.Tostring(DropdownList1.SelectedItem.Text);
or
TextBox1.Text =  Convert.Tostring(DropdownList1.SelectedValue.Text);
TextBox1.Text =  Convert.Tostring(DropdownList1.SelectedValue.VAlue);
  Permalink  
v2
Comments
Sampath Lokuge 29-Nov-13 8:14am
   
+ 5 :)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

txtbox.Text = ddl.SelectedItem.Value.ToString();
Smile | :)
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Try like below

In your aspx page

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
        onselectedindexchanged="DropDownList1_SelectedIndexChanged">
        <asp:ListItem>1</asp:ListItem>
        <asp:ListItem>2</asp:ListItem>
        <asp:ListItem>3</asp:ListItem>
        <asp:ListItem>4</asp:ListItem>
</asp:DropDownList>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

in your aspx.cs page

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        TextBox1.Text = DropDownList1.SelectedItem.Value;
    }
  Permalink  
Comments
Member 11381964 10-Apr-15 3:56am
   
hi.. I have a dropdownlist in which i am displaying concatenated fields of datatable and i want to display one of the fields from the dropdownlist selected item in a text box . Is it possible? plz help.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

simple atleast try at once by your self over net Smile | :)

TextBox1.Text =  Convert.Tostring(DropdownList1.SelectedValue);


Thanks,
Ambesha
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 26 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100