0

I have a site with a number of gridview's and want to add more client side function. I am trying to understand how to bind a gridview with jQuery. As best I can understand it, a jQuery function will need to interact with a webservice to populate the gridview? Is there anyway for jQuery to interact with subs in the code-behind of the webpage?

4
  • why not use updatepanel control to load the gridview on demand? Commented Feb 24, 2011 at 17:51
  • I use the update panel in some cases but like I mentioned in another comment, I would like to off-load the populating of gridviews until after page load. I thought jQuery would help me work that magic! Commented Feb 24, 2011 at 17:55
  • 1
    You can still do that with UpdatePanels. Set the internal content to Visible=false, then call __doPostBack('updatepaneluniqueid','true') (for example - the 2nd parameter will be used by your code to decide the contents should be visible) when page loading is complete to render them. I could see in a very content-heavy page this might be useful to better control the order in which things are rendered. Commented Feb 24, 2011 at 17:57
  • 1
    Also if you're not doing this already, enable CDN in your ScriptManager which will cause all the MS scripts to be referenced from Microsoft's CDN instead of your server. It's good for the internet and will take load off your server, but unless bandwidth is a problem it probably won't cure your slow pages. Commented Feb 24, 2011 at 18:07

2 Answers 2

2

This is kind of apples and oranges. If you use jQuery to populate your grid from the client, then you aren't really using a GridView any more, except, perhaps, as a template.

But basically, if you wanted to use client-side code to populate and manage the contents of a a grid that is based on a large server-side database, you'll be running ajax queries from the client for every event that needs new data (such as paging) and rebuilding/repopulating the grid.

jQuery interacts with server code through ajax. So any information you need at the client will have to come from something on the server designed specifically to provide that information: a WebService, WebMethod, or dedicated page that can be queried with GET and returns html.

This is certainly doable, but why do you want to do this? All your functionality already exists, and it's generally more work to make something with heavy client/server interaction work entirely from javascript, even if starting from scratch. But there's nothing stopping you from using jQuery to decorate and add new functionality to your existing server-based grids.

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

2 Comments

Thanks jamietre. 'Why I would want to do this' is a great question! I think paragraph 2 of your reply is want I might want to do. My concerns are keeping the user on the same page, fearful of the .net AJAX auto-created bloat (if any) and being able to allow the user to interact with cells inside of a gridview through jquery.
Not sure what you mean about keeping the user on the same page. For ajax bloat, well, we all worry about that, but unless you are addressing a specific performance problem, you have to ask yourself if you're making work where none is needed. Finally, for interacting with cells, nothing should stop you from using jQuery to decorate your grid after its rendered and add any functionality you want.
0

Why do you want to do this? Are you experiencing performance problems? In this case, you should consider reeveluating your data fetching methods.

3 Comments

Thanks, Jan-Frederik, Yes there is some performance issues, and I know that's entirely another subject. My most intensive data laden gridview page loads in about 8 seconds on average. For my users it's not a deal breaker, but I almost think that loading the page, then loading the gridviews asynchronously may even be more palatable. (A subject for another day also)
That is a a huge problem, 8 seconds per page load? But I doubt it has to do with using UpdatePanels. You need to figure out exactly what is causing the delays and deal with it. Making assumptions about the cause will most likely end up creating a lot of work without solving the actual problem...
i know where the page load problem is - it's from more than 10 dataset requests on pageload. The query performance is a different story. I was thinking that if I got my head around better client side controls I would rebuild the page and hopefully condense and minimize the db requests.

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.