0
I managed to make my JArray
return a list, in this list contains 03 Ids, but the way the system was done, they made a way to return only the first Array
.
Follows the code of what is returning to the View
:
[HttpPost]
public PartialViewResult DadosUser2(ListaUsers user_IDs)
{
UserBLL bll = new UserBLL(context.db);
JArray users = bll.DadosUser2(user_IDs.user_ids);
if (users.Count == 0)
throw new Exception("Usuário não encontrado user_id " + user_IDs);
JObject u = (JObject)users[0];
return PartialView("DadosUser", u);
}
How can I do this JObject
return all data and not only the first position?
Why not return all the
Array
? That is to say:return PartialView("DadosUser", users);
.– João Martins
That line
JObject u = (JObject)users[0];
is making return only the first. Take it out and put onlyreturn PartialView("DadosUser", users);
– Leandro Amarilha
when making this report that you suggested arises error Error code: PX100 Message: Cannot convert type 'Newtonsoft.Json.Linq.Jarray' to 'Newtonsoft.Json.Linq.Jobject'
– user139372
That’s because your View is only expecting a Jobject, you have to change in your view to accept a Jarray
– Julio Borges