Faqs on asp.net,c#,vb.net and sqlserver2005

this blog covers all the Faqs related to .net technologies like asp.net,vb.net,c#.net,ajax,javascript and sqlserver2005.

Mar 14, 2008

ListView and DataPager in ASP.NET 3.5

New controls in asp.net 3.5
I spent a couple of hours today looking over the ListView and DataPager controls in ASP.NET 3.5. Both controls sound interesting and both provide welcome new features to the ASP.NET control arsenal. Although I'm a little wary of having yet another list control (as if we haven't enough of those already between DataGrid, DataList, Repeater, GridView and now the ListView) the ListView control kind of combines functionality of all of these controls into one. Maybe the most important feature of this control is that like the Repeater control it provides much more control over the rendering process at the cost of more markup code in the page.
The ListView is a sort of hybrid between a DataGrid and Repeater that combines the free form templating of the Repeater with the editing features of the data grid. It looks interesting because it basically allows you much more control over the layout than a DataGrid does while still giving you many of the more advanced features of the data grid. The ListView doesn't support paging natively, so the DataPager serves as an external control to provide paging features. The advantage of a separate control is that it gives you much more control about what the pager looks like and where it can be placed on the page - anywhere basically. The Pager is essentially an extender control that extends the ListView with paging capabilities.
The ListView Control
Using the ListView for basic data display is very similar to using a Repeater. You have the ListView control and a set of templates that you can apply which include:
LayoutTemplate
ItemTemplate
AlternatingItemTemplate
SelectedItemTemplate
EmptyItemTemplate
EmptyDataTemplate (?)
ItemSeparatorTemplate
GroupTemplate
GroupSeparatorTemplate
EditItemTemplate
InsertItemTemplate
That's a lot of templates . There are a few new ones here like GroupTemplate and InsertItemTemplate. I haven't figured out how GroupTemplate works, but InsertItemTemplate certainly is a nice addition so you can handle both editing and adding in the same space (previously with a DataGrid you had to insertion externally or insert data manually into a DataTable to display the empty row).


Reference:
http://www.west-wind.com/WebLog/posts/127340.aspx

Happy Programming

0 Comments:

Post a Comment

<< Home