Click here to Skip to main content
16,018,919 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
here is my question.... i have to get the text from the drop down list and display it in the next line...

i have a drop down with values of some companies... when i select a company name tht company name has to display below... plzzz send me what to write in the aspx page as well as aspx.cs page...
Posted
Comments
jaideepsinh 19-Jul-13 6:31am    
Accept as answer and vote.

ASP.NET
<asp:DropDownList ID="ddlselect" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlselect_SelectedIndexChanged">
       <asp:listitem value="customer_id">All Transactions  
       <asp:listitem value="cr_date">Date
</asp:DropDownList>
                                                       
<asp:label id="lblshow" runat="server' >

on in ddlselect_SelectedIndexChanged
C#
lblshow.text = ddlselect.selecteditem.text
 
Share this answer
 
v4
Comments
jaideepsinh 19-Jul-13 6:30am    
5+ve.
Hello Vamsna,

You just take label at which you want to display that company name.

Then create drop down selected index change event and make auto postback event of dropdown true then write code to print your selected company name at you label like this:
Write this code in .aspx
ASP.NET
<asp:DropDownList ID="ddl" OnSelectedIndexChanged="ddl_SelectedIndexChange" runat="server" AutoPostBack="True"> 
</asp:DropDownList>

Write this code in .cs:
C#
protected void ddl_SelectedIndexChange(object sender, EventArgs e)
{
    lbl.text=ddl.SelectedItem.Text
}


Accepts as answer and vote if help to you.
 
Share this answer
 
v2
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.ToString();
    }


Reference: how to display selected values from dropdown list asp.net[^]

Hope it helps! :)
 
Share this answer
 
v2
aspx page

add onSelectedIndexChanged="comboBoxtest_SelectedIndexChanged" to the combo.

CS File
C#
private void comboBoxtest_SelectedIndexChanged(object sender, EventArgs e)
{
   var combotext = comboBoxtest.Text;     
   label1.Text = combotext ;
}
 
Share this answer
 
v2

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