Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
4.00/5 (3 votes)
See more:

how to display selected values from dropdown list in textbox in asp.net
Posted

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.

C#
TextBox1.Text =  Convert.Tostring(DropdownList1.SelectedItem.Value);

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

or
C#
TextBox1.Text =  Convert.Tostring(DropdownList1.SelectedValue.Text);
TextBox1.Text =  Convert.Tostring(DropdownList1.SelectedValue.VAlue);
 
Share this answer
 
v2
Comments
Sampath Lokuge 29-Nov-13 8:14am    
+ 5 :)
C#
txtbox.Text = ddl.SelectedItem.Value.ToString();

:)
 
Share this answer
 
Try like below

In your aspx page

XML
<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

C#
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        TextBox1.Text = DropDownList1.SelectedItem.Value;
    }
 
Share this answer
 
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.
simple atleast try at once by your self over net :)

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



Thanks,
Ambesha
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900