0

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

3 Answers 3

1

Calling WebMethods 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.

Sign up to request clarification or add additional context in comments.

3 Comments

I Don't Want Scriptmanager, Json Data With How To Make GridView Data Load ? Please Help...
You can't load a server-side control with client-side scripting (using JSON) without either ScriptManager/UpdatePanel or a post-back. It's that simple. Your other option would be to have your WebMethod return the HTML of the GridView and then use jQuery to dump the HTML on to the page.
how its make "WebMethod return the HTML of the GridView and then use jQuery to dump the HTML on to the page"; im sorry, im junior developer :)
1

Using jQuery to directly call ASP.NET AJAX page methods

Comments

0

You cannot interact with the page in a WebMethod.

You should use an UpdatePanel instead.

1 Comment

Man...you're stealing all my thunder this morning. :-P

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.