Click here to Skip to main content
15,915,019 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear Sir,

I am doing a project in asp.net, and am stuck with an issue.

I am using jquery ajax code for post to code behind window. Here is the Below code.


JavaScript
$.ajax({
    type: "POST",
    url: "Home.aspx/ShowBooked_Items", // the method we are calling
    contentType: "application/json; charset=utf-8",
    data: JSON.stringify({ "Item_ID": $(this).attr('id') }),
    dataType: "json",
    success: function (result) {

                ShowPopUp();
            },



            });



And here is the Code that am using in code behind,

C#
[WebMethod]
    
    public static void ShowBooked_Items(int Item_ID)
    { // something
}


The above codes are working properly. But when i put some code for bind the Grid in the "ShowBooked_Items" method, but i didn't get the grid in that method . I didn't get any control inside that method

Please Help me,

Thanks

Dileep
Posted

Hi,

As Christian Graus told you to pass your data through json to bind your datagird, you can refer this[^] article. it may help you.

Without postback you can not bind your datagrid from code behind. the only way is to update your grid information using json or may be you can use Update panel so you will not feel page refresh.

Hope above article helps you,

Thanks
-Amit Gajjar
 
Share this answer
 
Comments
dilzz 20-Aug-12 7:43am    
Thank you sir....
AmitGajjar 20-Aug-12 7:52am    
if my solution help you then you can mark it as answer/upvote to help others to identify correct solution.
You can't access the controls, it's not a postback. So you need to use JSON to pass in ALL the data you need from the client, not just the one id. You then need to write jquery code to populate your controls when the call succeeds.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900