Click here to Skip to main content
15,891,698 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.
Posted
Comments
MT_ 15-Oct-12 1:51am    
Where is the "question" !

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

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


                       </div>



ddreligion loadin on page load event

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

    });



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

C#
[System.Web.Services.WebMethod]

        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();
                c.castid=ds.Tables["Cast"].Rows[i][0].ToString();
                c.cast=ds.Tables["Cast"].Rows[i][1].ToString();
                cast.Add(c);
            }
             
            return cast;
        }</casts></casts></casts>
 
Share this answer
 
v2
use selectedIndexchange event and bind child dropdown
or you can use jquery for same logic
 
Share this answer
 
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
 
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