I have a dilemma with handling JSON data in my code behind to bind it to an obout grid. While I am aware of passing data using the <WebMethod>
, I've encountered limitations as the method is static, making it difficult to bind the data to any grid control.
My current approach involves calling a code behind method from JavaScript and passing the data as a parameter to the method. How can this be achieved effectively?
users = [];
for (var i = 0; i < usersInfo.length; i++) {
user = {
UserName : usersInfo[i].UserName,
Email : usersInfo[i].Email,
Status : status
};
users.push(user);
}
var results = "";
$('#lblError').val('');
if (users.length > 0) {
//Need to find a way to pass the `users` data to ShowResults code behind method.
}
Code Behind
public void ShowResults(List<UsersInfo> users)
{
oboutGrid.DataSource = users;
oboutGrid.DataBind();
}
public partial class UsersInfo
{
public string UserName { get; set; }
public string Email { get; set; }
public string Status { get; set; }
}