How do I Update a GridView from a Page Method from code behind? How do I Update a GridView from a Page Method from code behind? json json

How do I Update a GridView from a Page Method from code behind?


You can dynamically/programmatically build the GridView control. Then in your WebMethod, you can call RenderControl() method to retrieve the HTML content of the rendered GridView control. Return that content from the WebMethod and have the callback JavaScript function inject the HTML content into your placeholder element's innerHTML property.

Another option is to do your data binding on the client-side. So all the WebMethod has to do is pass back the data (excluding presentational markup), for example in a JSON-type format. Then you can use something like javascript templates to render the grid with data. This approach takes GridView control completely out of the picture, but depending on your needs, it may be a viable option.