Datagrid vs Datalist vs Repeater
-
Can someone elaborate the major differences between these three controls (Datagrid/Datalist/Repeater) ???? Why would I use a Datagrid over the other 2? Why would I use a Datalist over the other 2? Why would I use a Repeater over the other 2? I've been reading on these controls, and they all seem to do the exact same thing. Please, can I get some insight on this matter? Thanks, Jon G www.Gizmocoder.com
-
Can someone elaborate the major differences between these three controls (Datagrid/Datalist/Repeater) ???? Why would I use a Datagrid over the other 2? Why would I use a Datalist over the other 2? Why would I use a Repeater over the other 2? I've been reading on these controls, and they all seem to do the exact same thing. Please, can I get some insight on this matter? Thanks, Jon G www.Gizmocoder.com
Hi Jon.
DataGrid
,DataList
, andRepeater
are similar controls in that you can use them all to present data in a common way (by setting theDataSource
property calling theDataBind
() method). TheRepeater
control gives you the most flexibility in how the data is presented. You use templates -HeaderTemplate
,ItemTemplate
,FooterTemplate
, and others - to layout how you want the data to look. I have used theRepeater
to generate everything from an html <table>, to an html <ul> list, to a simple comma-separated text list in a single line. TheDataList
control specifically presents your data in an html <table>. It's simple to use, uses templates like theRepeater
control to govern the layout of individual cells, and allows some degree of flexibility over the use of columns (with properties likeRepeatCount
andRepeatDirection
). In aDataList
table, rows and columns are for layout only; it's not the case that one row would correspond to one record of data, with columns representing fields. Rather, each cell represents one record of data, and the layout is horizontal or vertical depending on the properties. I've used theDataList
when presenting a page of catalog images... each cell was one image with comments (one record of data) and I laid them across three columns of the table. TheDataGrid
control also presents data as an html <table>, but in this case each row is intended to represent one record of data, with columns representing (typically) individual fields. TheDataGrid
provides some built-in support for inline editing, paging, sorting... it is the most complicated of the three to use, but learning its intricacies has paid off for me in creating UI's for data-editing/reporting applications. Check out Marcie's site http://www.datagridgirl.com[^] for a bunch more on theDataGrid
. I hope this helps.