Eswar Datta

Eswar Datta

  • NA
  • 115
  • 6.6k

Web services and jquery ajax

Dec 26 2018 1:06 AM
[WebMethod]
public void Getcountries()
{
List<oCountries> countries = new List<oCountries>();
SqlConnection con = new SqlConnection(constr);
SqlCommand command = new SqlCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "RETRIEVE_DATA";
command.Connection = con;
con.Open();
SqlDataReader sdr = command.ExecuteReader();
while (sdr.Read())
{
oCountries countriesS = new oCountries();
countriesS.CID = Convert.ToInt16(sdr["CTRY_ID"]);
countriesS.CName = sdr["CRTY_NAME"].ToString();
countries.Add(countriesS);
}
JavaScriptSerializer js = new JavaScriptSerializer();
Context.Response.Write(js.Serialize(countries));
}
 
 
 
 
How to bind this data to dropdown list using jquery ajax 

Answers (1)