Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need some help.
I want to hadle panel from a dropdownlist.Suppose i have a dropdownlist,named dropdownlist1.It has two location on it.I want to use two indivitual panel for each loactions.when i'll select location1,then panel1 will visible and if i choose location2 then panel2 will visible.
Here's my code..please help me.

thnk u...


Here's my .NET code

Location:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="changed">
<asp:ListItem>howrah
<asp:ListItem>kolkata

<asp:Panel ID="Panel3" runat="server" Width="456px" Visible="False">
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True">
<asp:ListItem>ballygung
<asp:ListItem>garia
<asp:ListItem>jadabpur


<asp:Label ID="Label4" runat="server" Text="Label">

<asp:Panel ID="Panel4" runat="server" Visible="False" Width="458px">
<asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="True">
<asp:ListItem>Nabanna
<asp:ListItem>colg ghat
<asp:ListItem>ds lane




Here's my C# code

namespace problem
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

C#
<pre lang="c#">
protected void changed(object sender, EventArgs e)
{
Label3.Text = "your current location : " + DropDownList1.SelectedItem.Text;
if (DropDownList1.SelectedValue.ToString()=="howrah")
Panel3.Visible = true;
else
Panel4.Visible = false;
}
Posted

1 solution

C#
protected void Page_Load(object sender, EventArgs e)
{
   if(!IsPostBack)
      HidePanels();
}
protected void changed(object sender, EventArgs e)
{
  HidePanels();
}
private void HidePanels()
{
    Label3.Text = "your current location : " + DropDownList1.SelectedItem.Text;
    if (DropDownList1.SelectedValue.ToString()=="howrah")
    {
      Panel3.Visible = true;
      Panel4.Visible = false;
    }else
    {
      Panel3.Visible = false;
      Panel4.Visible = true;
    }
}
 
Share this answer
 
v2
Comments
Debanjan Mondal 11-Jun-14 0:12am    
now if I want to add 2nd panel with another location,how does it possible?
Debanjan Mondal 11-Jun-14 14:14pm    
if more than two location are available,then what is the solution?
switch case is needed?
and how?
Debanjan Mondal 11-Jun-14 14:53pm    
thanks,..i did it..

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