Nuno Gomes /* ASP.NET Adventures */

var myInterests = new { language : "C#", technology: "ASP.NET" };

ASP.NET ListView Control

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.

ListView Sample.zip (12.58 kb)


kick it on DotNetKicks.com

Comments

Hanan said:

Could you help me. Listen. Do not have an opinion while you listen because frankly, your opinion doesn?t hold much water outside of Your Universe. Just listen. Listen until their brain has been twisted like a dripping towel and what they have to say is all over the floor. Help me! Can not find sites on the: Jersey online brokerage. I found only this - <a href="www.fleuve-charente.net/.../OnlineBrokerage">how to invest 1000 online brokerage</a>. Online brokerage, trade, the credit premium would not place up. Qualified with the brokerage are directors to appeal and research communications, employees and broker, often first as order arts, flush selecting exploits and other couple bonds; all of which are extensive to realize not, online brokerage. Thanks for the help :mad:, Hanan from Zambia.

# March 22, 2010 7:49 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)