.cs Код здесь
[WebMethod]
public DataTable GetName()
{
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("CodeNo", typeof(string));
dt.Rows.Add("Delhi","D01");
dt.Rows.Add("Noida", "N01");
return dt;
}
код здесь
$(document).ready(function () {
$().ready(function () {
$.ajax({
type: "POST",
url: "Home.aspx/GetName",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
$("#City").get(0).options.length = 0;
$("#City").get(0).options[0] = new Option("--Select--", "-1");
?.......Here ....................?
});
},
error: function () {
alert("Failed to load ");
}
});
});
Мой выход Put
- -Выберите - только , но я хочу ... DataTable Row ("Delhi", "Noida") в SelectList или DropDpwnlist как
-Select--
Delhi
Noida