Advertisement
Guest User

jQuery -how to Bind DropDownlist with Sql Database -Asp.net

a guest
Apr 11th, 2012
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. [WebMethod]
  2. public DataTable GetName()
  3. {
  4. DataTable dt = new DataTable();
  5. dt.Columns.Add("Name", typeof(string));
  6. dt.Columns.Add("CodeNo", typeof(string));
  7. dt.Rows.Add("Delhi","D01");
  8. dt.Rows.Add("Noida", "N01");
  9. return dt;
  10. }
  11.  
  12. $(document).ready(function () {
  13. $().ready(function () {
  14. $.ajax({
  15. type: "POST",
  16. url: "Home.aspx/GetName",
  17. data: "{}",
  18. contentType: "application/json; charset=utf-8",
  19. dataType: "json",
  20. success: function (msg) {
  21. $("#City").get(0).options.length = 0;
  22. $("#City").get(0).options[0] = new Option("--Select--", "-1");
  23. ?.......Here ....................?
  24. });
  25. },
  26. error: function () {
  27. alert("Failed to load ");
  28. }
  29. });
  30. });
  31.  
  32. -Select--
  33. Delhi
  34. Noida
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement