Populate Dropdown on selecetd index cahnge

Posted by Lalitha86 under ASP.NET on 8/31/2012 | Points: 10 | Views : 845 | Status : [Member] | Replies : 1
cannot
clear the Dropdown items on selected index changed

the items get added one below the other

protected void ddlSection_SelectedIndexChanged(object sender, EventArgs e)
{

ddlSegement.ClearSelection();
if (ddlSection.SelectedIndex == 1)
{
ddlSegement.Items.Add("Equity");
ddlSegement.Items.Add("Derivatives");
ddlSegement.Items.Add("Mutual Funds");
ddlSegement.Items.Add("FII's");

}


if (ddlSection.SelectedIndex == 2)
{

ddlSegement.Items.Add("Companies/ Securities");
ddlSegement.Items.Add("Capital listed");
ddlSegement.Items.Add("Amount offered");
ddlSegement.Items.Add("Indices");
ddlSegement.Items.Add("Ratios");




}


and ASpx page code is
<tr><td >Select Section</td><td colspan="3"><asp:DropDownList ID="ddlSection" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlSection_SelectedIndexChanged" >
<asp:ListItem Value="0" Selected="True" >Select</asp:ListItem>
<asp:ListItem Value="1" >Turnover Satistics</asp:ListItem>
<asp:ListItem Value="2">Listing and Captial</asp:ListItem>
<asp:ListItem Value="3">Membership and TWS</asp:ListItem>
<asp:ListItem Value="4">Client Statistics</asp:ListItem>


</asp:DropDownList></td></tr>

<tr ><td >Select Segement</td><td colspan="3"><asp:DropDownList ID="ddlSegement" runat="server" AutoPostBack="true" >

</asp:DropDownList></td></tr>




Responses

Posted by: Maheshvishnu on: 8/31/2012 [Member] Starter | Points: 25

Up
0
Down
Try this

ddlSelection.items.RemoveAt(ddlSelection.selectedindex)


mahesh

Lalitha86, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response