Reputation: 1440
Aspx Page:
$(document).ready(function() {
$("#btnn").click(function() {
$.ajax({
type: "POST",
url: "TestPage.aspx/emp",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
}
});
});
});
CodeBehind:
public void grdload()
{
GridView1.DataSource = GetEmployee("Select * from Employee");
GridView1.DataBind();
}
[WebMethod]
public static void emp()
{
TestPage re = new TestPage();
re.grdload();
}
I Can't Gridview Data Load ? How To Make GridView Data Load?
Thank You
Upvotes: 0
Views: 4820
Reputation: 245429
Calling WebMethod
s like that in ASP.NET is meant to return a JSON dataset that you can parse through Javascript, not reload controls.
You should look in to using the ASP.NET AJAX toolkit and getting the ScriptManager
and UpdatePanel
on your page and using regular .NET code to update your GridView
.
Upvotes: 1
Reputation: 887453
You cannot interact with the page in a WebMethod.
You should use an UpdatePanel instead.
Upvotes: 0