0

i have 3 dropdownlist when i select first dropdown fill 2nd and 3rd when i select 3rd dropdown any value it's automatic select index 1 both dropdown 2nd and 3rd. i want do some work on 3rd dropdown selected index change. here is my aspx code

body>
<form id="form1" runat="server">
<div>
    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
        onselectedindexchanged="DropDownList1_SelectedIndexChanged">
        <asp:ListItem>1</asp:ListItem>
        <asp:ListItem>2</asp:ListItem>
        <asp:ListItem>3</asp:ListItem>
        <asp:ListItem Selected="True">select</asp:ListItem>
    </asp:DropDownList>
    <asp:DropDownList ID="DropDownList2" runat="server">
    </asp:DropDownList>
    <asp:DropDownList ID="DropDownList3" runat="server"  AutoPostBack="True" 
        onselectedindexchanged="DropDownList3_SelectedIndexChanged">
    </asp:DropDownList>
</div>
</form>

and my cs code is

HotelBAL objhotel = new HotelBAL();
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        //objhotel.searchHotelRoomType(DropDownList1, "1");

    }
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    string id = DropDownList1.SelectedItem.Text;
    objhotel.searchHotelOccupancy(DropDownList2, id);
    objhotel.searchHotelMealPlan(DropDownList3, id);
}
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{

}
4

2 回答 2

1

Please make sure that you are filling you dropdown list in

if (!Page.IsPostBack)
    {
          //LoadDropdownListHere();
    }
于 2013-09-17T09:43:58.500 回答
0
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" 
    onselectedindexchanged="DropDownList2_SelectedIndexChanged">
    <asp:ListItem Selected="True">select</asp:ListItem>
    <asp:ListItem>1</asp:ListItem>
    <asp:ListItem>2</asp:ListItem>
    <asp:ListItem>3</asp:ListItem>
</asp:DropDownList>

Add default value in the drop down. and in the event

 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string id = DropDownList1.SelectedItem.Text;
        if(!id.Equals("select"))
         {
           objhotel.searchHotelOccupancy(DropDownList2, id);
           objhotel.searchHotelMealPlan(DropDownList3, id);
         }
    }

Try this..

于 2013-09-17T09:45:55.540 回答