Hi if anyone want to display dropdown selected data in textbox than firstly set the Autopostback=true for Dropdown and write the code given below:-
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Show ddltext</title> </head> <body> <form id="form1" runat="server"> <div> <asp:DropDownList ID="ddldetails" runat="server" AutoPostBack="true" onselectedindexchanged="ddldetails_SelectedIndexChanged"> <asp:ListItem Value="0">--Select--</asp:ListItem> <asp:ListItem Value="1">Delhi</asp:ListItem> <asp:ListItem Value="2">Calcutta</asp:ListItem> <asp:ListItem Value="3">Pune</asp:ListItem> </asp:DropDownList>
<asp:TextBox ID="txtname" runat="server"> </asp:TextBox> </div> </form> </body> </html>
Code Behind Code Write the code given below:-
protected void ddldetails_SelectedIndexChanged(object sender, EventArgs e) { txtname.Text = ddldetails.SelectedItem.Text; }
No comments:
Post a Comment