I have JSON data which I need to pass to code behind and bind to obout grid. I know we can pass data using <WebMethod>
. But in Webmethod I cannot bind the data to obout grid and any grid. because it is static webmethod.
So Now I trying to call code behind method from javascript and pass the data as parameter to method. How can we do that?
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) {
//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; }
}