Wednesday, March 17, 2010

ASP. Net ListView DataBinding

For presenting data in list form, we have several options in Asp.Net like ListView, DataList, Repeater, GridView, DropDownList, etc... Since we have a variety of controls to choose from, the control can be selected based on specific requirements. For e.g. single column with single selection the DropDownList is the perfect choice. If paging, sorting, edit is required then GridView will be the right choice. If just need to repeat some html code, then Repeater will work out to be better. This article is focused on ListView.


DataBinding is quiet similar to GridView

DataBinding in ListView is almost similar to GridView. There is not much difference. There is a requirement of ItemPlaceHolder. By default the name of that place holder is itemPlaceholder. Asp.Net allows us to custom name (id) also.

Flexibility in rendering

This ListView is one of the best controls while flexibility is taken into consideration. With the concept of Item Place Holder, we can specify/ configure where the items have to be placed (rotated). In this example, I have made a two column layout with liquid flow. The number of horizontal cells can be adjusted based on the resolution while resizing the browser.

Templates in ListView

There are few templates that will ease the development effort using ListView. If you have worked in GridView earlier, then basic templates in ListView are similar to GridView Templates. There are few special templates. I am highlighting the templates in the following list. These templates can be used customize rendering.

LayoutTemplate


GroupTemplate


ItemTemplate


AlternatingItemTemplate


EditItemTemplate


InsertItemTemplate


ItemSeparatorTemplate


GroupSeparatorTemplate


EmptyItemTemplate


EmptyDataTemplate


SelectedItemTemplate
For Source Code refer here(VB.Net ListView)

0 comments:

Post a Comment