Question: Before I start , I would like to say one thing, this is not connected with the database.

I am developing a website using asp.net. Here am stuck due to some confusions.  

In one of my page, there are number of panels available. Each panel has one label(State Name) and two text boxes. At top of the page, search bar **(drop down list)** is provided with State Names.

Now here the scenario is, If a user selects a state from drop down then the particular panel with respective label(state name) should be searched.

**For Example** 

Am having a State A, B and C are there in my Drop down list **(Search bar)** and at the same time am also having a three panels such as Panel x(State A as label name and two text boxes), Panel y(State B as label name and two text boxes), and Panel z(State C as label name and two text boxes) in Default.aspx page.

**Now I need, if user selects State A from drop down list then the particular panel(which label is having State A) should display with all controls** 

"No connection with database"

Hope am not confusing. Any help would be more helpful to me.  

Thanks in advance.

Answer: 
Assuming label1 is in Panel1and label2 is in Panel2

```
protected void Dropdownlist1_Changed(object sender, EventArgs, e)
{
    string labelTxt= Dropdownlist1.SelectedValue;
    if(labelTxt == label1.Text)
    {
        Panel1.Visible = true;
        Panel2.Visible = false;
    }
    else if(labelTxt == label2.Text)
    {
        Panel1.Visible = false;
        Panel2.Visible = true;
    }

}

```
It easy to but you need to be more logical means there is no relation between you panel and drop drown list.

```
<asp:DropDownList runat="server" ID="ddlState" AutoPostBack="True" 
    OnSelectedIndexChanged="ddlState_SelectedIndexChanged"  >
    <asp:ListItem Text="StateA" Value="Panel1" />
    <asp:ListItem Text="StateB" Value="Panel2" />
</asp:DropDownList>

```

And in C#

```
protected void ddlState_SelectedIndexChanged(object sender, EventArgs, e)
{
    //hide all the panels 
    for(int i=0;i<ddlState.Items.Count;i++)
    {
       var control= ddlState.Items[i].Value;
      if(this.FindControl(control)!=null)
           this.FindControl(control).Visible=false;
    }

    //show the selected dropdown list panel
    string item = Dropdownlist1.SelectedValue;
    if(this.FindControl(item)!=null)
       this.FindControl(item).Visible =true;

}

```