Hello i want to Bind Drop down using ajax in asp.net , but it is not working
plz help me
see my code:
- $(document).ready(function () {
- debugger;
- $.ajax({
- type: "POST",
- url: "~/Settings/City.aspx/BindCountry",
- data: '{}',
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- sucess: function (r) {
- var ddlcountrry = $("[id*=MainContent_ddlCountry]");
- ddlcountrry.empty().append('');
- $.each(r.d, function () {
- ddlcountrry.append($("").val(this['Value']).html(this['Text']));
- });
- },
- failure: function () {
- alert("Failed!");
- }
- });
- });
- [WebMethod]
- public List
BindCountry() - {
- DataSet dsCountry = ObjGlobalBll.FetchCountry(ObjGlobal);
- DataTable dt = dsCountry.Tables[0];
- //DataRow dr = dt.Rows[0];
- List
Country = new List (); - foreach (DataRow dr in dt.Rows)
- {
- Country.Add(new ListItem
- {
- Text = dr["CountryName"].ToString(),
- Value = dr["CountryID"].ToString()
- });
- }
- return Country;


Ravindra SinghPosted Jun 5, 2018, 5:45 AM