Click here to Skip to main content
15,073,043 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have three dropdownlist.first one dropdownlist am selected country for example india.and then second dropdown list am selecting state and third dropdownlist am i selecting district na showing relevant information in dropdownlist.
MT_ 15-Oct-12 1:51am
Where is the "question" !

<div class="fields">
                           <asp:DropDownList ID="ddreligion" runat="server" AutoPostBack="false" Width="150px">
                       <div class="labels">
                       <div class="fields">

                               <asp:DropDownList ID="ddCast" runat="server">


ddreligion loadin on page load event

using jquery ajax call i load cast second drop down list
$('#<%=ddreligion.ClientID%>').change(function () {
        $('#<%=ddCast.ClientID %>').empty().append($("<option></option>").html('Loading....'));
            type: "POST",
            url: 'Searchformatches.aspx' + '/populatecast',
            data: '{regionid: ' + $('#<%=ddreligion.ClientID%>').val() + '}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: OnDoctorsPopulated,
            failure: function (response) {


this is my web service
it is inside of my web form Searchformatches.aspx


        public static List<casts> populatecast(string regionid)
            DataSet ds;
            SqlDataAdapter da;
            SqlConnection con;
            String constr = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
            con = new SqlConnection(constr);
            List<casts> cast = new List<casts>();

            da = new SqlDataAdapter("select castid,cast from dbo.castes where religionid =  " + regionid, con);
            ds = new DataSet();
            da.Fill(ds, "Cast");
            int i=0;
            casts c;
            for ( i=0;i<=ds.Tables [0].Rows .Count -1;i++)
                c = new casts();
            return cast;
use selectedIndexchange event and bind child dropdown
or you can use jquery for same logic
put the drop down list in update panel
one by one in order write the server side events
<asp:updatepanel xmlns:asp="#unknown">
ddcountry load the daat in page load event

ddstate use where condtion ddcountry.selectedValue
ddcity use where condtion ddstate .selectedValue

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