Within an asp webform project I am making a call to a web service that returns a result collection as follows.
Pseudo code return of collection
content (items are key value pair)
ID, 001
Title , My Book
DateCreated , 10/10/2011
Author, JSmith
What I would like to do is on the initial return only display the title of the book in a data repeater and then once the user clicks on a detail display the remaining fields in a separate pane div container of the form. I’ve done this in the past with generic lists in Silverlight and in MVC however in this project I cannot use either.
In conducting some research I have seen where people are using json to make similar calls. However I debugged with fiddler and I can see that entire collection is being returned to the UI so it seems I should be able to go directly at the collection vs making a new call back to the server? Within the UI I am not using asp:net controls but standard html to render the data in the data in the UI.
Example
<div class="resultcontainer">
<span class="labeltitle-small">Book Title</span><br />
<%= BookResults[0].Title %>
</div>
I’m able to query and return the results however where I am stuck is the best approach to display what I’ll refer to as secondary data for the associated record.
I’d really appreciate any suggestions on how (from the client) to only show a view value of the collection and then once a record is selected have the other values displayed to the user.
Thank you
Well, perhaps a bit obvious, but have you considered a little bit of AJAX, using
jQuery.ajax? You could attach an onclick even handler to the div and load the data in the appropriate part of the page when the user selects a particular book.You can return a partial view from the controller. The resulting HTML can be displayed in a div using something along the lines of
$("#detailDiv").html(partialView).