Hello all I have a project where I need to perform single value bindings from a collection. I am trying to create an asp.net web form website with a certain degree of separation without going to mvc. Within the site I have a page that invokes a method from a web service. This method returns a result collection. The page is designed to show the data in a structured layout vs grid or form view. Can someone point me in the right direction (links or sample ) upon how to perform single value bindings against a collection result in asp.net.
update
Just for clarification, the method will return a collection within that collection I have the following properties (FirstName LastName Height Weight). Is it possible to bind the collection to a section within the page and then within that section display a certain property?
<div id="section1" DataSource="peopleCollection">
<%# LastName %><br/>
<span>Height: <%# Height %></span><br/>
<span>Weight: <%# Weight %></span>
</div>
I’d like to do this using web forms and a pseudo implementation of MVC without using the MVC framework
Thanks in advance
Is ‘peopleCollection’ have a single element or multiple elements where each element has properties that need to be data-bound? If yes then you should able to use data bound control such as ListView/Repeater. What exactly is the issue here?
Or do you mean that ‘peopleCollection’ is really a dictionary (collection of name-value pairs) – so you have threes key into the dictionary i.e. height, wight and last-name? In such case, you can create dummy array with single element and bind it with repeater/list-view. For example,
in code-behind
in mark-up
EDIT:
For single element (with respective properties), you can still use repeater based approach. All you have to do is to put a single element array (or any enumerable collection) and bind with the repeater (or similar control).
But really speaking, you don’t really need data-binding with single element. You can also use markup such as
where
Peopleis a protected/public property exposing the single element.