TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Umer Ali
NA
139
7.1k
want to bind drop down using ajax
Jun 5 2018 4:52 AM
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(
'<option selected="selected" value="0">Please select</option>'
);
$.each(r.d,
function
() {
ddlcountrry.append($(
"<option></option>"
).val(
this
[
'Value'
]).html(
this
[
'Text'
]));
});
},
failure:
function
() {
alert(
"Failed!"
);
}
});
});
[WebMethod]
public
List<ListItem> BindCountry()
{
DataSet dsCountry = ObjGlobalBll.FetchCountry(ObjGlobal);
DataTable dt = dsCountry.Tables[0];
//DataRow dr = dt.Rows[0];
List<ListItem> Country =
new
List<ListItem>();
foreach
(DataRow dr
in
dt.Rows)
{
Country.Add(
new
ListItem
{
Text = dr[
"CountryName"
].ToString(),
Value = dr[
"CountryID"
].ToString()
});
}
return
Country;
Reply
Answers (
2
)
ASP.net core & Entity Framework Core in docker
How to launch my application in Cerner?