Click here to Skip to main content
11,789,710 members (62,419 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: event DropDownList
I m populating subcategory dropdown fom category dropdown.
but when i change category in category dropdown its "SelectedIndexChanged"event is not is my code:-

<td><asp:DropDownList ID="selectcategorydd" runat="server"
                class="styledselect_form_1" AutoPostBack="true"
            <asp:RequiredFieldValidator ID="rfvc" runat="server"
                ControlToValidate="selectcategorydd"  ForeColor="Red" ErrorMessage="Select category">*</asp:RequiredFieldValidator>
        <th valign="top" > SubCategory:</th>
        <td style="width:30%">
            <asp:DropDownList ID="selectscategorydd" runat="server" AutoPostBack="true" AppendDataBoundItems="True"

protected void Fill_Category()
           DataTable categorytbl = d.fill_category();
           selectcategorydd.DataSource = categorytbl;
           selectcategorydd.DataTextField = "CategoryName";
           selectcategorydd.DataValueField = "CategoryID";
           selectcategorydd.Items.Insert(0, "--Select--");

       protected void selectcategorydd_SelectedIndexChanged(object sender, EventArgs e)
           int catid = int.Parse(selectcategorydd.SelectedValue);
           DataTable t1 = d.cascadesubcat(catid);
           selectscategorydd.DataSource = t1;
           selectscategorydd.DataTextField = "SubCategoryName";
           selectscategorydd.DataValueField = "SubCategoryID";
           selectscategorydd.Items.Insert(0, "--Select--");
Note:- viewstate is also true in page directive.
Posted 3-Feb-13 19:59pm
JemiM at 4-Feb-13 5:22am
you have placed two dropdown with same id. Please give a unique Id to the controls.
rrjoshi2321992 at 4-Feb-13 5:30am
no its different..there is a diference of "s"
1st ID is "selectcategorydd"
2nd ID is "select's'categorydd"
JemiM at 4-Feb-13 5:35am
did you validate any controls while dropdown change?
rrjoshi2321992 at 4-Feb-13 5:58am
nop i m not validating any control in dropdown index change.

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

  Print Answers RSS
0 OriginalGriff 999
1 Maciej Los 765
2 KrunalRohit 686
3 CPallini 606
4 Richard MacCutchan 430

Advertise | Privacy | Mobile
Web01 | 2.8.1509028.1 | Last Updated 4 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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