Click here to Skip to main content
15,895,462 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
Hi, I am Manpreet doing B.Tech in computer science.
I am having problem in c# about dropdownlist that when I click on selected item, its related information displays in textboxes. How should I do coding for this?
Posted
Updated 29-Aug-11 19:41pm
v2
Comments
Prerak Patel 30-Aug-11 1:41am    
Use proper case.

Use the SelectedIndex property[^].

Once you have the value you have selected, fetch the values related to this index (the ones that you want to show in textboxes).
These will need to be fetched from the database or a temporary memory store.

Display these values.
 
Share this answer
 
XML
<asp:DropDownList  ID="DropDownList1"  runat="server"   AutoPostBack="true"          OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"    >
             <asp:ListItem>HyperLink</asp:ListItem>
             <asp:ListItem>PasswordRecovery</asp:ListItem>
             <asp:ListItem>PlaceHolder</asp:ListItem>
             <asp:ListItem>LoginName</asp:ListItem>
             <asp:ListItem>Label</asp:ListItem>
        </asp:DropDownList>

<asp:textbox id="TextBox1" runat="server" xmlns:asp="#unknown"></asp:textbox>



XML
<script runat="server">
    protected void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
        TextBox1.Text = "You Selected: " + DropDownList1.SelectedItem.Text;
    }
</script>



You can use database to store records.
 
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