473,396 Members | 1,966 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,396 software developers and data experts.

DataList column alignment?

I'm using DataList to present tabular data but am often having problems with
some rows column alignment being out of synch with the rest of the rows.

My DataList looks similar to this...:

<asp:datalist id="DataList1" runat="server">
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="400">
<tr>
<td width="100">First Name</td>
<td width="100">Surname</td>
<td width="100">DOB</td>
<td width="100">Gender</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table>
<tr>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"firstname") %></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"surname") %></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem, "dob")
%></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"gender") %></td>
</tr>
</table>
</ItemTemplate>
</asp:datalist>

....but if any data exceeds the maximum width of it's column, that particular
"cell" is getting expanded to accomodate the data. I think the problem lies
in using tables in the <ItemStyle> tags, so for each row, the table is
automatically altered to accomodate the data it hold. Of course, this makes
the final output look unprofessional.

Is there any way round this?

Thanks
Ben
Nov 19 '05 #1
5 3735
Ben,

Basically, you need to put everything in the same table:

<table border="0" cellpadding="0" cellspacing="0" width="400">
<colgroup span="4" width="100" />
<asp:datalist id="DataList1" runat="server">
<HeaderTemplate>
<tr>
<td>First Name</td>
<td>Surname</td>
<td>DOB</td>
<td>Gender</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# DataBinder.Eval(Container.DataItem, "firstname")
%></td>
<td><%# DataBinder.Eval(Container.DataItem, "surname")
%></td>
<td><%# DataBinder.Eval(Container.DataItem, "dob") %></td>
<td><%# DataBinder.Eval(Container.DataItem, "gender")
%></td>
</tr>
</ItemTemplate>
</asp:datalist>
</table>

Eliyahu

"Ben Fidge" <Be******@discussions.microsoft.com> wrote in message
news:DE**********************************@microsof t.com...
I'm using DataList to present tabular data but am often having problems with some rows column alignment being out of synch with the rest of the rows.

My DataList looks similar to this...:

<asp:datalist id="DataList1" runat="server">
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="400">
<tr>
<td width="100">First Name</td>
<td width="100">Surname</td>
<td width="100">DOB</td>
<td width="100">Gender</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table>
<tr>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"firstname") %></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"surname") %></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem, "dob") %></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"gender") %></td>
</tr>
</table>
</ItemTemplate>
</asp:datalist>

...but if any data exceeds the maximum width of it's column, that particular "cell" is getting expanded to accomodate the data. I think the problem lies in using tables in the <ItemStyle> tags, so for each row, the table is
automatically altered to accomodate the data it hold. Of course, this makes the final output look unprofessional.

Is there any way round this?

Thanks
Ben

Nov 19 '05 #2
Hi Eliyahu

I tried this and it didn't work for me. I'll have another go though. Have
you used it yourself?

When I put <tr> etc tag between <ItemTemplate> tags (withou an accompayning
<table> tag), the IDE says that <tr> tags can't be used in this context

Ben

"Eliyahu Goldin" wrote:
Ben,

Basically, you need to put everything in the same table:

<table border="0" cellpadding="0" cellspacing="0" width="400">
<colgroup span="4" width="100" />
<asp:datalist id="DataList1" runat="server">
<HeaderTemplate>
<tr>
<td>First Name</td>
<td>Surname</td>
<td>DOB</td>
<td>Gender</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# DataBinder.Eval(Container.DataItem, "firstname")
%></td>
<td><%# DataBinder.Eval(Container.DataItem, "surname")
%></td>
<td><%# DataBinder.Eval(Container.DataItem, "dob") %></td>
<td><%# DataBinder.Eval(Container.DataItem, "gender")
%></td>
</tr>
</ItemTemplate>
</asp:datalist>
</table>

Eliyahu

"Ben Fidge" <Be******@discussions.microsoft.com> wrote in message
news:DE**********************************@microsof t.com...
I'm using DataList to present tabular data but am often having problems

with
some rows column alignment being out of synch with the rest of the rows.

My DataList looks similar to this...:

<asp:datalist id="DataList1" runat="server">
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="400">
<tr>
<td width="100">First Name</td>
<td width="100">Surname</td>
<td width="100">DOB</td>
<td width="100">Gender</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table>
<tr>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"firstname") %></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"surname") %></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem,

"dob")
%></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"gender") %></td>
</tr>
</table>
</ItemTemplate>
</asp:datalist>

...but if any data exceeds the maximum width of it's column, that

particular
"cell" is getting expanded to accomodate the data. I think the problem

lies
in using tables in the <ItemStyle> tags, so for each row, the table is
automatically altered to accomodate the data it hold. Of course, this

makes
the final output look unprofessional.

Is there any way round this?

Thanks
Ben


Nov 19 '05 #3
I use this with a repeater. A datalist may create it's own tables, that's
why it won't like yours. Do you have a particular reason for using a
datalist rather than a repeater?

One thing is absolutely clear. There is no way of aligning columns other
than putting them in the same table.

Eliyahu

"Ben Fidge" <Be******@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.com...
Hi Eliyahu

I tried this and it didn't work for me. I'll have another go though. Have
you used it yourself?

When I put <tr> etc tag between <ItemTemplate> tags (withou an accompayning <table> tag), the IDE says that <tr> tags can't be used in this context

Ben

"Eliyahu Goldin" wrote:
Ben,

Basically, you need to put everything in the same table:

<table border="0" cellpadding="0" cellspacing="0" width="400">
<colgroup span="4" width="100" />
<asp:datalist id="DataList1" runat="server">
<HeaderTemplate>
<tr>
<td>First Name</td>
<td>Surname</td>
<td>DOB</td>
<td>Gender</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# DataBinder.Eval(Container.DataItem, "firstname")
%></td>
<td><%# DataBinder.Eval(Container.DataItem, "surname")
%></td>
<td><%# DataBinder.Eval(Container.DataItem, "dob") %></td> <td><%# DataBinder.Eval(Container.DataItem, "gender")
%></td>
</tr>
</ItemTemplate>
</asp:datalist>
</table>

Eliyahu

"Ben Fidge" <Be******@discussions.microsoft.com> wrote in message
news:DE**********************************@microsof t.com...
I'm using DataList to present tabular data but am often having problems
with
some rows column alignment being out of synch with the rest of the

rows.
My DataList looks similar to this...:

<asp:datalist id="DataList1" runat="server">
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="400">
<tr>
<td width="100">First Name</td>
<td width="100">Surname</td>
<td width="100">DOB</td>
<td width="100">Gender</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table>
<tr>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"firstname") %></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"surname") %></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem,

"dob")
%></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"gender") %></td>
</tr>
</table>
</ItemTemplate>
</asp:datalist>

...but if any data exceeds the maximum width of it's column, that

particular
"cell" is getting expanded to accomodate the data. I think the problem

lies
in using tables in the <ItemStyle> tags, so for each row, the table is
automatically altered to accomodate the data it hold. Of course, this

makes
the final output look unprofessional.

Is there any way round this?

Thanks
Ben


Nov 19 '05 #4
There's no particular reason I'm using a DataList other than that's what I've
always used. I'll give Repeater a go.

Thanks

Ben

Does repeater use the same templates
"Eliyahu Goldin" wrote:
I use this with a repeater. A datalist may create it's own tables, that's
why it won't like yours. Do you have a particular reason for using a
datalist rather than a repeater?

One thing is absolutely clear. There is no way of aligning columns other
than putting them in the same table.

Eliyahu

"Ben Fidge" <Be******@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.com...
Hi Eliyahu

I tried this and it didn't work for me. I'll have another go though. Have
you used it yourself?

When I put <tr> etc tag between <ItemTemplate> tags (withou an

accompayning
<table> tag), the IDE says that <tr> tags can't be used in this context

Ben

"Eliyahu Goldin" wrote:
Ben,

Basically, you need to put everything in the same table:

<table border="0" cellpadding="0" cellspacing="0" width="400">
<colgroup span="4" width="100" />
<asp:datalist id="DataList1" runat="server">
<HeaderTemplate>
<tr>
<td>First Name</td>
<td>Surname</td>
<td>DOB</td>
<td>Gender</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# DataBinder.Eval(Container.DataItem, "firstname")
%></td>
<td><%# DataBinder.Eval(Container.DataItem, "surname")
%></td>
<td><%# DataBinder.Eval(Container.DataItem, "dob") %></td> <td><%# DataBinder.Eval(Container.DataItem, "gender")
%></td>
</tr>
</ItemTemplate>
</asp:datalist>
</table>

Eliyahu

"Ben Fidge" <Be******@discussions.microsoft.com> wrote in message
news:DE**********************************@microsof t.com...
> I'm using DataList to present tabular data but am often having problems with
> some rows column alignment being out of synch with the rest of the rows. >
> My DataList looks similar to this...:
>
> <asp:datalist id="DataList1" runat="server">
> <HeaderTemplate>
> <table border="0" cellpadding="0" cellspacing="0" width="400">
> <tr>
> <td width="100">First Name</td>
> <td width="100">Surname</td>
> <td width="100">DOB</td>
> <td width="100">Gender</td>
> </tr>
> </table>
> </HeaderTemplate>
> <ItemTemplate>
> <table>
> <tr>
> <td width="100"><%# DataBinder.Eval(Container.DataItem,
> "firstname") %></td>
> <td width="100"><%# DataBinder.Eval(Container.DataItem,
> "surname") %></td>
> <td width="100"><%# DataBinder.Eval(Container.DataItem,
"dob")
> %></td>
> <td width="100"><%# DataBinder.Eval(Container.DataItem,
> "gender") %></td>
> </tr>
> </table>
> </ItemTemplate>
> </asp:datalist>
>
> ...but if any data exceeds the maximum width of it's column, that
particular
> "cell" is getting expanded to accomodate the data. I think the problem
lies
> in using tables in the <ItemStyle> tags, so for each row, the table is
> automatically altered to accomodate the data it hold. Of course, this
makes
> the final output look unprofessional.
>
> Is there any way round this?
>
> Thanks
> Ben


Nov 19 '05 #5
On Wed, 22 Jun 2005 06:34:03 -0700, Ben Fidge wrote:
I'm using DataList to present tabular data but am often having problems with
some rows column alignment being out of synch with the rest of the rows.

My DataList looks similar to this...:

<asp:datalist id="DataList1" runat="server">
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="400">
<tr>
<td width="100">First Name</td>
<td width="100">Surname</td>
<td width="100">DOB</td>
<td width="100">Gender</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table>
<tr>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"firstname") %></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"surname") %></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem, "dob")
%></td>
<td width="100"><%# DataBinder.Eval(Container.DataItem,
"gender") %></td>
</tr>
</table>
</ItemTemplate>
</asp:datalist>

...but if any data exceeds the maximum width of it's column, that particular
"cell" is getting expanded to accomodate the data. I think the problem lies
in using tables in the <ItemStyle> tags, so for each row, the table is
automatically altered to accomodate the data it hold. Of course, this makes
the final output look unprofessional.

Is there any way round this?

Thanks
Ben

The Header should have the table but not the table end. There should not
be a table in the ItemTemplate (unless it is for another purpose)

Nov 19 '05 #6

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

Similar topics

0
by: Alex | last post by:
Interested in more .NET stuff visit www.dedicatedsolutions.co.uk The DataList is not as powerful as the DataGrid. It requires more work from you since it has no default data presentation format....
2
by: moondaddy | last post by:
using vb.net I have a datalist where the Repeat layout has: Columns 2 Direction Horizontal Layout Table I want to put a spacer column inbetween the 2 columns for better control of...
0
by: TCORDON | last post by:
I have a DataList set with Horizontal Alignment, it is supposed to display 3 items per row, and it does this verry well but when the result is less that 3 records (2) then it separates both items...
1
by: Rachel Devons | last post by:
All, I have a table with three rows, and within each row I have a DataList that is set to use 3 columns. The problem I'm having is that each DataList sets it's columns to be different widths so...
3
by: Danny Tuppeny | last post by:
Hi all, I've got a DataList that's bound to a datasource with two columns (well, two that matter). One is called GigDate, and one is called RescheduledFromDate. GigDate doesn't allow NULLs,...
0
by: TCORDON | last post by:
I have a DataList set with Horizontal Alignment, it is supposed to display 3 items per row, and it does this verry well but when the result is less that 3 records (2) then it separates both items...
5
by: Vikas Kumar | last post by:
i had coded like this <ItemTemplate> <table width="100%"> <tr width="100%"> <td width="25%"><%#DataBinder.Eval(Container.DataItem,"FName")%></td> <td width="25%"><input type=text ...
4
by: rn5a | last post by:
A DataList displays 3 columns - Product, Category & Price. These columns are populated with records from a SQL Server 2005 DB table. Apart from the above 3 DB columns that the resultset retrieves,...
1
by: Brock | last post by:
First note that I am using Framework 1.1. I have an .aspx page that is displaying a list of employees, but only the Employee Number, First Name, Last Name, and Title. It is working great. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.