On page load, I have my DataTable results available which I need to pass back to the javascript for processing.
What are my options?
#datacontrol {display: none;}
How can I do this?
After trying several of the above options, I've found #3 (ASP.NET inline expressions) to be the best choice for accessing an ADO query result such as a DataTable or DataSet since it was the quickest to implement and had no additonal round trips due to the fact the inline expressions are resolved during the page construction.
I tried #5 (bind data to data control, then hide it), but it was noticeably slower and I had problems finding a control that would expose all the features of a DataTable/DataSet. There are a handful of data controls that you can bind records to, but what I found was that much of the "nice-ities" that come with a DataSet/DataTable are lost when converting to a repeater control or such. If you use one of the more full featured ASP controls available to get more of those features back, you lose on performance since those controls are meant for read/write and to render the content for display. And it wasn't as simple as I expected to access the data as it is in the code behind.
I thought about #4 (passing data thru ASP's ClientScript.RegisterStartupScript), but didn't feel like serializing/deserializing every object I need to expose and working though any hiccups that come with it. It just didn't seem like the right way. I suppose it would be fine for simpler objects though.
And #1 (serialize data to a hidden field) is pretty much the same concept as the above #4 (passing data thru ASP's ClientScript.RegisterStartupScript so I didn't bother with that one either.
The other (2nd best) possibility is to do #2 (using webmethod/webservice) as @Sundeep and @ron_tornambe have pointed out. However, this option adds an extra round trip to the page request and since the above scenario has the DataTable/DataSet ready for consumption on page load it is not optimal for me. If it wasn't for that I'd say it was equal to my first choice of #3 (ASP.NET inline expressions) since you'll get the full featured object to work with.