I have JavaScript code that calls a method in ASP.NET. Basically, I have a SqlDataSource connected to a GridView, and I want to change the SelectCommand of the DataSource without causing a postback.
Right now, I am using __dopostback method, but as I said I don’t want the page to reload. I just want the GridView to update. Is this possible?
That’s not how is done. There are many approaches to this but the easiest is to enclose your content inside an UpdatePanel and drop a ScriptManager on your page.
for example:
Now all interactions on your page will be done via Ajax.
Better approach (the one I use currently)
Use jQuery to make your Ajax calls in conjunction with a Web Service.
Sample code:
Using jQuery on the client-side, you can do something like this:
I highly recommend looking at these links: