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
Aleena Saviour
NA
519
87.8k
Bind a dropdownlist inside ajax
Dec 10 2016 1:32 AM
This is the code to bind dropdownlist inside ajax success using the dataset returned from webmethod...
JavaScript function
function Check(ddldesig)
{
alert('hi');
alert(ddldesig);
//var selectedText = $(ddldesig).text();
var selectedText=ddldesig.options[ddldesig.selectedIndex].text;
var selectedValue = $(ddldesig).val();
alert("Selected Text: " + selectedText + " Value: " + selectedValue);
var obj = {};
obj.desigId = selectedValue;
obj.desig = selectedText;
$.ajax({
type: "POST",
url: "JobAssign.aspx/FillEmp",
data: JSON.stringify(obj),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response){
alert(response.d);
var ddlEmp = $("[id*=ddlEmp]");
var dtset = jQuery.parseJSON(response.d);
var dtEmp = dtset["Employee"];
ddlEmp.empty().append('<option selected="selected" value="-1">Select</option>');
$.each(dtEmp, function () {
ddlEmp.append($("<option></option>").val(this['EmpId']).html(this['FirstName']));
});
//});
},
failure: function (response){
alert("failed"+response.d);
}
});
}
Webmethod
public static string FillEmp(int desigId, string desig)
{
DataTable dt = new DataTable();
DataSet ds = new DataSet();
try
{
objEmpBL = new EmployeeBL();
objEmpBL.EmpId = 0;
objEmpBL.EmpCode = "";
objEmpBL.CompId = 0;
objEmpBL.CatId = 0;
objEmpBL.DeptId = 0;
objEmpBL.ActDesgId = desigId;
objEmpBL.VisaIssue = "";
objEmpBL.VisaExpiry = "";
dt = objEmpBL.EmpReportSelect();
dt.TableName = "Employee";
ds.Tables.Add(dt);
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
return ds.GetXml();
}
In the above code at the javascript function I got the correct datatable as response..but the extraction fails..any help....
Reply
Answers (
5
)
Only assignment, call, increment, decrement, and new object
Bind Recourse in Full schedular Calendar from EntityFramewor