best way to approach this problem

S

Stimp

I wish to create a table comparing three vehicle specs by having three
separate columns of data (one column for each vehicle).

e.g.
| Car1 | Car2 | Car3
Central locking | Yes | No | No
Power Steering | No | Yes | Yes
Airbag | Yes | Yes | Yes
...

The list of features as well as the list of cars with features is pulled
from a database.
There can be 1, 2, or 3 cars compared at one time (i.e. not always 3).

The design has to be pretty flexible, so that probably rules out
DataGrids.

How would I create this format using Datalists and/or Repeaters?

Would I first create a datalist to vertically output the names of the
features (i.e. the first column), then dynamically add 1, 2, or 3
vertical datalists to output the features for the 1, 2, or 3 cars by
using a horizontal repeater??

Any advice would be great!
Thanks,
Peter
 
S

S.M. Altaf [MVP]

If you just rotated the table 90 degrees, you'd make life easier for
yourself. Have the 3 features up on top. These can be your 'columns'. As
for your cars, you can now have any number of cars displayed in the rows
below it. So you can use a datagrid or a repeater, whatever you feel like.

HTH
Altaf
 
S

Stimp

If you just rotated the table 90 degrees, you'd make life easier for
yourself. Have the 3 features up on top. These can be your 'columns'. As
for your cars, you can now have any number of cars displayed in the rows
below it. So you can use a datagrid or a repeater, whatever you feel like.

HTH
Altaf

Altaf, thanks I've managed to create a DataTable with Features as column
names, and cars as rows.

Now I'm having some trouble trying to loop through my DataTable to
output each row... I've decided to output the data to a literal since
it's easier and saves me having to re-rotate the table back 90 degrees.

Here's my code for outputting the datatable... assume that the
FeatureArray contains the names of the columns...

Dim sOutputFeatures As System.Text.StringBuilder = New
System.Text.StringBuilder

Dim i As Integer
Dim tblFeatures As New DataTable("Items")
Dim colFeatures As DataColumn
Dim rowFeatures As DataRow

For i = 0 To FeatureArray.Count - 1

sOutputFeatures.Append("<TR>")
sOutputFeatures.Append("<TD>" & FeatureArray(i) & "</TD>")

For Each rowFeature In tblFeatures.Rows(i)
For Each colFeature In tblFeatures.Columns

sOutputFeatures.Append("<TD>" & rowFeatures(colFeatures) & "</TD>")
Next
Next

sOutputFeatures.Append("</TR>")
Next


my problem seems to lie with the line of code:

"For Each rowFeature In tblFeatures.Rows(i)"...

it won't let me use the '(i)' part since it says:

"Expression is of type System.Data.DataRow, which is not a collection
type"

Obviously I've gotten my syntax wrong here, but I can't seem to figure
out the proper format. Any ideas?

Thanks in advance,
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top