Click here to Skip to main content
12,895,911 members (51,648 online)
Click here to Skip to main content
Add your own
alternative version

Stats

12.6K views
2 bookmarked
Posted 15 Apr 2010

ASP.NET ListView Control

, 15 Apr 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
Some time ago I needed to render hierarchical data to a / elements structure and also be able to render a special attribute to the Html elements. Using TreeView control I found no better way than re-implement the Render method, loosing the out-of-the-box binding process.

Some time ago I needed to render hierarchical data to a <ul>/<li> elements structure and also be able to render a special attribute to the <li> Html elements.

Using TreeView control I found no better way than re-implement the Render method, loosing the out-of-the-box binding process.

Since I want to have a control similar to TreeView with all its binding richness I decide to write a ListView control.

This is the typical declaration I want to achieve:

<NG:ListView ID="orderedlistView1" runat="server" DataSourceID="SiteMapDataSource1" 

    Mode="Ordered">

  <DataBindings>

    <NG:ListNodeBinding DataMember="SiteMapNode" AttributeField="Url" TextField="Title" />

    <NG:ListNodeBinding DataMember="SiteMapNode" AttributeField="Url"

        TextField="Url" Depth="1"/>

    <NG:ListNodeBinding DataMember="SiteMapNode" AttributeField="Title"

        TextField="Title" Depth="2"/>

  </DataBindings>

</NG:ListView>

It looks pretty familiar...

In ListView control you can set the Mode property to choose whether to render an ordered list (<ol>) or an unordered list (<ul>).

Using the ListNodeBinding you can also use the AttributeField property to specify aditional attributes to rendered in the <li> html element (ex: <li Url="my Url" >some text</li>).

Also, there's no hierarchy depth limit.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Nuno M. F. Gomes
Architect everis
Portugal Portugal
Over 13 years of experience in the Software Development working mainly in the banking and insurance industry.

Over 3 year of experience as Operations Team Leader focused on Infrastructure Management and Software Configuration Management.

I've been honored with the Microsoft Most Valuable Professional (MVP) Award for three consecutive years, 2010, 2011 and 2012, in recognition to exceptional technical contributions and leadership.

Current / Recent Technical Projects
- Dominican Republic Instance management, including 2nd line System management, capacity management, SW monitoring and deploy management
- Colombian SECOPII Instance management, including 2nd line System management, capacity management, SW monitoring and deploy management
- Vortal Main Instance management, including 2nd line System management, capacity management, SW monitoring and deploy management
- Vortal Development ecosystem management, including Server management, , capacity management, SW monitoring and deploy management

Areas of Specialization:
- Operations Management - ISO 20000 & ISO 27001 driven
- Team Management and Coaching
- Technology Leadership, Solutions/Architecture
- Product life cycle management, Continuous Integration
- Technological background in Microsoft frameworks and tools.

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170424.1 | Last Updated 15 Apr 2010
Article Copyright 2010 by Nuno M. F. Gomes
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid