Ajax with ASP.net Gridview and Hidden Div questions

I am coming from a background in coldfusion and trying to re-create a feature in another application using asp.net with C#. Right now I am trying to create a gridview that binds a list of contacts to it, but I want the ability that when you click on a button of some sort, or the row itself, that a hidden div will pop up and the details of that contact will be loaded into the div utilizing ajax. I would also like it to blackout the background so that the div has to be closed before the person can click anything in the background.

I have seen this implemented on many websites and I don't know why I'm having so much trouble accomplishing it. To me, trying to figure out how to put javascript code into a dynamically bound gridview is my biggest challenge. I'm sure If I did this by just writing inline .net code I could accomplish it how I did in coldfusion which was just writing a loop that output each row of the table and created the dynamic link. If anyone has done something similar to this please let me know. The most important thing with the clickable row is that it needs to pass the contactid through the javascript call so that the right contact can be loaded in the detail view div. Thanks for any help you can provide.
Who is Participating?
Alexandre SimõesConnect With a Mentor Manager / Technology SpecialistCommented:
You have the answer in your question... use the templating syntax (inline code as you call it) and do exactly what you want as you said it.

Ah... and don't feel bad about it... :)

The GridView renders an HTML table just like you need everything else is just overhead.
Trying to mix server-side controls with client-side logic is just like signing a long term pain in the butt contract. You'll find yourself hacking with ScriptManager to inject javascript from the server and probably hacking ajax with update panels...
You'll have problems with the controls ID and you need to inspect what on earth the server-side control renders so that you can hijack it properly.

From my experience I tell you: Just don't do it.

If you don't want to do the in-line loop, request the data with an AJAX call or serialize it to json and do you're loop in javascript.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.