473,385 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Data display question

Hi,

I don't know if I'm doing anything wrong, but I'm trying to list 3
products per line on a page. So for example, if a user searches for
'widget' and he gets 4 results, I would have something like:

w1 w2 w3
w1 info w2 info w3 info
---------- ------------ -----------
w4
w4 info
----------

I'm using a DataList control, with <ItemTemplate> something like:
<table>
<tr><td>name</td></tr>
<tr><td>info</td></tr>
</table>

the problem is that the products are not lining up, for the obvious
reason that the DataList control is putting each product in its own
table. Specifying the height of the table or its rows doesn't help.

Obviously, what I need is a control that can put the names of the
products in the first row, and the info in the second row, then the
second set of products (4-6) in the third and fourth rows, and so on.

I don't know if the repeater can accomplish that. It just doesn't make
sense to use it, since it will only be able to put one item per row
(right?).

Should I just create my own table and iterate through the products,
filling it up as I go? or is there a better solution?

Thanks,

Alex

Jan 18 '06 #1
3 1245
Alex,

The solution is to put the datalist inside another table and make the items
into the table cells.

<table><tr>
<asp:DataList>
<asp:ItemTemplate>
<td><table width="100%">
<tr><td>name</td></tr>
<tr><td>info</td></tr>
</table></td>
<asp:ItemTemplate>
<asp:SeparatorTemplate>
</tr><tr>
</asp:SeparatorTemplate>
</asp:DataList>
</tr></table>

Eliyahu

"Alex Greenberg" <mi*********@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi,

I don't know if I'm doing anything wrong, but I'm trying to list 3
products per line on a page. So for example, if a user searches for
'widget' and he gets 4 results, I would have something like:

w1 w2 w3
w1 info w2 info w3 info
---------- ------------ -----------
w4
w4 info
----------

I'm using a DataList control, with <ItemTemplate> something like:
<table>
<tr><td>name</td></tr>
<tr><td>info</td></tr>
</table>

the problem is that the products are not lining up, for the obvious
reason that the DataList control is putting each product in its own
table. Specifying the height of the table or its rows doesn't help.

Obviously, what I need is a control that can put the names of the
products in the first row, and the info in the second row, then the
second set of products (4-6) in the third and fourth rows, and so on.

I don't know if the repeater can accomplish that. It just doesn't make
sense to use it, since it will only be able to put one item per row
(right?).

Should I just create my own table and iterate through the products,
filling it up as I go? or is there a better solution?

Thanks,

Alex

Jan 18 '06 #2
Actually, the separator template in this case has to be a bit more
sophisticated. You will want to render </tr><tr> after every third item
rather than after each one. The way of doing that is handle ItemDataBound
event to catch the items with ItemType = Separator and to make the separator
template generate </tr><tr> only for every third separator.

Eliyahu

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Alex,

The solution is to put the datalist inside another table and make the
items into the table cells.

<table><tr>
<asp:DataList>
<asp:ItemTemplate>
<td><table width="100%">
<tr><td>name</td></tr>
<tr><td>info</td></tr>
</table></td>
<asp:ItemTemplate>
<asp:SeparatorTemplate>
</tr><tr>
</asp:SeparatorTemplate>
</asp:DataList>
</tr></table>

Eliyahu

"Alex Greenberg" <mi*********@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi,

I don't know if I'm doing anything wrong, but I'm trying to list 3
products per line on a page. So for example, if a user searches for
'widget' and he gets 4 results, I would have something like:

w1 w2 w3
w1 info w2 info w3 info
---------- ------------ -----------
w4
w4 info
----------

I'm using a DataList control, with <ItemTemplate> something like:
<table>
<tr><td>name</td></tr>
<tr><td>info</td></tr>
</table>

the problem is that the products are not lining up, for the obvious
reason that the DataList control is putting each product in its own
table. Specifying the height of the table or its rows doesn't help.

Obviously, what I need is a control that can put the names of the
products in the first row, and the info in the second row, then the
second set of products (4-6) in the third and fourth rows, and so on.

I don't know if the repeater can accomplish that. It just doesn't make
sense to use it, since it will only be able to put one item per row
(right?).

Should I just create my own table and iterate through the products,
filling it up as I go? or is there a better solution?

Thanks,

Alex


Jan 18 '06 #3
Thanks Eliyahu,

Although this solution clearly works, I'm opting for the table-looping
solution. I'm not sure which is faster though. I will try both and
see.

Regards,

Alex

Jan 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: StepH | last post by:
Hi, I'm building a little application, which the goal is to: 1./ Collect data via Serial line and or via a file (for playback). 2./ Display these data as graph, oscilloscope, ... How manage...
1
by: CR | last post by:
"How to" question... I have an Access Database with only one table (tblBooks) with 5 fields: id, TestNumber, Book, Author, ReadingLevel, PointValue. I would like to have alphabetical listing of...
10
by: Bart Goeman | last post by:
Hi, I have a question about how to put redundant information in data structures, initialized at compile time. This is often necessary for performance reasons and can't be done at run time (data...
3
by: Robin Thomas | last post by:
I am fairly new to ASP.NET so I think I am missing something fundamental. Anyway, quite often I am pulling data from a database, but then I need to use that data to produce more data. A simple...
5
by: Scott Reynolds | last post by:
Hello! I developed a web application to display results from the database. Now I need to add search function, to search, sort and filter data. My question is, which way is better... 1)...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
0
by: tedqn | last post by:
1. Unlimited drill down. Is it possible to define an XSL that can loop all the way and parse result? question 1 answer 1 followup question followup answer followup question followup answer...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
0
by: Grip | last post by:
Hi, I have gone throught the group and Microsoft's online help and have seen many suggestions but I am still seeking clarity: 1. I have an excel spreadsheet. Column A contains text that may...
12
by: petter | last post by:
Hi! I have two questions: one question that regards the COUNT-function, and one about how to display a month even if I don’t have any data for that month. I have an Access database where I want...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.