Hi I'm trying to return string to my textboxes by click on a repeater row item here the web method;
[WebMethod]
public string OrderGet(int User)
{
using (Models.DermabonEntities db = new Models.DermabonEntities())
{
var get = (from i in db.OrderAddress
where i.Id == User
select i.UserId).ToList();
var a = get.FirstOrDefault().ToString();
var res = (from i in db.OrderAddress
where i.UserId == a
select i.FirstName).FirstOrDefault();
var res1 = (from i in db.OrderAddress
where i.UserId == a
select i.LastName).FirstOrDefault();
object[] array1 = new object[2];
array1[0] = res;
array1[1] = res1;
return array1.ToString();
}
}
As you see I return array1 here the ajax code;
function siparisAl(id) {
var User = id;
$.ajax({
dataType: "json",
type: "POST",
contentType: "application/json",
url: "/Admin/WebService/Control.asmx/OrderGet",
data: JSON.stringify({ 'User': User }),
success: function (data) {
$("#ContentPlaceHolder1_Name").val(data.d[0]);
},
error: function () {
}
});
return false;
}
the problem is when I run it writes S to the Name textbox why it could be ? And How can I fix it I have several names in my database instead of 'S' please help
and I've tried console.log(data.d) = it says System.Object[]