c# - Database Driven Dependant Dynamic DropDownList on ASP.NET -


i have 2 drop down list follows in addproduct.aspx

<asp:dropdownlist id="ddlbrand" runat="server"></asp:dropdownlist>     <asp:dropdownlist id="ddlsubbrand" runat="server"></asp:dropdownlist> 

at code behind file have used these codes brand drop down list database driven

ddlbrand.datasource = brandmanager.getallbrand();             ddlbrand.datatextfield = "brandname";             ddlbrand.datavaluefield = "brandid";             ddlbrand.databind();             listitem item = new listitem();             item.value = "0";             item.text = "--select brand--";             ddlbrand.items.insert(0, item); 

im trying subbrand drop down list dynamic , change according selected in brand drop down list. both drop down lists next each other , i'm not sure how value of selected brand selected. i'm planning parse in selected value data base using statement in class retrieves values database.

   "select subbrandid,subbrandname " +    " dateofbirth subbrand " +    " brandid = @inbrandid" 

once brand gets selected want post of selected item:

<asp:dropdownlist id="ddlbrand" runat="server" onselectedindexchanged="brandselectedindexchanged" autopostback="true"></asp:dropdownlist> 

in code-behind have add method:

protected void brandselectedindexchanged(object sender, eventargs args) {     int id;     if (int.tryparse(ddlbrand.selectedvalue, out id)) {         //do thing here id of brand, e.g. bind sub brands.     } } 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -