I need to display data from a database in a html table. I am currently using a ListView control.
I want the final HTML table to render something like the following, where some rows have a rowspan attribute greater than one. The reason for this is that some fields have several rows of information, but correspond to the same logical entry.
For example:
|---------|---------|----------|----------|
| data | data |data | data |
| | |----------| |
| | |data | |
| | |----------| |
| | |data | |
|---------|---------|----------|----------|
| data | data |data | data |
| | |----------| |
| | |data | |
| | |----------| |
| | |data | |
|---------|---------|----------|----------|
| data | data |data | data |
| | |----------| |
| | |data | |
| | |----------| |
| | |data | |
| | |----------| |
| | |data | |
| | |----------| |
| | |data | |
|---------|---------|----------|----------|
What is the easiest way to accomplish this in ASP.net?
Not too elegant solution for
ListView. The main idea is to useRepeaterinside theListViewand bind all the sub-data(I mean data from the third column in your example) except the first record to it.and code behind:
this outputs data in the format you want.
But if the usage of
ListViewis not necessary you could take a look ontoGridView. There is more elegant way to do this by using it – ASP.NET GridView RowSpan using RowCreated Event – How to add Table Dynamic RowSpan with GridView article.