Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Appriciate u can let me the precious solution :

I have a project in which i have to fill the DropDownList(DDProjectIDList from database), and if user select the projectID, then corresponding customer list(DropDownList) must be filled . These all data is there in the sql database.

I have to do it by AJAX.

Thanx for your help
Shaan
Posted

Use Google or Use Code Project Search...
Use:Cascading Dropdown + ASP.NET as keywords...

you would get lots of material, code, control on it!
 
Share this answer
 
Shaan,

Follow the steps
1. Place both the dropdowns in a UpdatePanel.
2. Add onchange event for the first dropdown.
3. In the event handler fill the second dropdown (on serverside only as do for any other).
 
Share this answer
 
Shaan
here i changed the state based on the country ..

in javascript add this.. based on ur requirement..

<pre lang="xml"><asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>

    <asp:DropDownList ID="ddlcountry" runat="server" AutoPostBack="True"
            onselectedindexchanged="ddlcountry_SelectedIndexChanged" >
    </asp:DropDownList>
        <br />
        <br />
    <br />
    <asp:DropDownList ID="ddlstate" runat="server"
            
            AutoPostBack="True" ></asp:DropDownList>



and in codebahind jst add bind the data for example in ddlcountry_SelectedIndexChanged event(i have used LINQ)
IEnumerable<State> res = db.States.Where(s => s.CountryId ==int .Parse (ddlcountry.SelectedValue));<br />
ddlstate.DataSource = sl;<br />
        ddlstate.DataTextField = "StateName";<br />
        ddlstate.DataValueField = "StateId";<br />
        <br />
        ddlstate.DataBind();<br />
<br />
 
Share this answer
 

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