Click here to Skip to main content
14,424,779 members
Rate this:
Please Sign up or sign in to vote.
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 20:41pm
v2
Comments
Prerak Patel 30-Aug-11 1:41am
   
Use proper case.
Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

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



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

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




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