473,698 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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">Fir st Name</td>
<td width="100">Sur name</td>
<td width="100">DOB </td>
<td width="100">Gen der</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate >
<table>
<tr>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"firstname" ) %></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"surname") %></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item, "dob")
%></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"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 3769
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.Data Item, "firstname" )
%></td>
<td><%# DataBinder.Eval (Container.Data Item, "surname")
%></td>
<td><%# DataBinder.Eval (Container.Data Item, "dob") %></td>
<td><%# DataBinder.Eval (Container.Data Item, "gender")
%></td>
</tr>
</ItemTemplate>
</asp:datalist>
</table>

Eliyahu

"Ben Fidge" <Be******@discu ssions.microsof t.com> wrote in message
news:DE******** *************** ***********@mic rosoft.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">Fir st Name</td>
<td width="100">Sur name</td>
<td width="100">DOB </td>
<td width="100">Gen der</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate >
<table>
<tr>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"firstname" ) %></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"surname") %></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item, "dob") %></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"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.Data Item, "firstname" )
%></td>
<td><%# DataBinder.Eval (Container.Data Item, "surname")
%></td>
<td><%# DataBinder.Eval (Container.Data Item, "dob") %></td>
<td><%# DataBinder.Eval (Container.Data Item, "gender")
%></td>
</tr>
</ItemTemplate>
</asp:datalist>
</table>

Eliyahu

"Ben Fidge" <Be******@discu ssions.microsof t.com> wrote in message
news:DE******** *************** ***********@mic rosoft.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">Fir st Name</td>
<td width="100">Sur name</td>
<td width="100">DOB </td>
<td width="100">Gen der</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate >
<table>
<tr>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"firstname" ) %></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"surname") %></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item,

"dob")
%></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"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******@discu ssions.microsof t.com> wrote in message
news:01******** *************** ***********@mic rosoft.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.Data Item, "firstname" )
%></td>
<td><%# DataBinder.Eval (Container.Data Item, "surname")
%></td>
<td><%# DataBinder.Eval (Container.Data Item, "dob") %></td> <td><%# DataBinder.Eval (Container.Data Item, "gender")
%></td>
</tr>
</ItemTemplate>
</asp:datalist>
</table>

Eliyahu

"Ben Fidge" <Be******@discu ssions.microsof t.com> wrote in message
news:DE******** *************** ***********@mic rosoft.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">Fir st Name</td>
<td width="100">Sur name</td>
<td width="100">DOB </td>
<td width="100">Gen der</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate >
<table>
<tr>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"firstname" ) %></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"surname") %></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item,

"dob")
%></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"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******@discu ssions.microsof t.com> wrote in message
news:01******** *************** ***********@mic rosoft.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.Data Item, "firstname" )
%></td>
<td><%# DataBinder.Eval (Container.Data Item, "surname")
%></td>
<td><%# DataBinder.Eval (Container.Data Item, "dob") %></td> <td><%# DataBinder.Eval (Container.Data Item, "gender")
%></td>
</tr>
</ItemTemplate>
</asp:datalist>
</table>

Eliyahu

"Ben Fidge" <Be******@discu ssions.microsof t.com> wrote in message
news:DE******** *************** ***********@mic rosoft.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">Fir st Name</td>
> <td width="100">Sur name</td>
> <td width="100">DOB </td>
> <td width="100">Gen der</td>
> </tr>
> </table>
> </HeaderTemplate>
> <ItemTemplate >
> <table>
> <tr>
> <td width="100"><%# DataBinder.Eval (Container.Data Item,
> "firstname" ) %></td>
> <td width="100"><%# DataBinder.Eval (Container.Data Item,
> "surname") %></td>
> <td width="100"><%# DataBinder.Eval (Container.Data Item,
"dob")
> %></td>
> <td width="100"><%# DataBinder.Eval (Container.Data Item,
> "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">Fir st Name</td>
<td width="100">Sur name</td>
<td width="100">DOB </td>
<td width="100">Gen der</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate >
<table>
<tr>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"firstname" ) %></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"surname") %></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item, "dob")
%></td>
<td width="100"><%# DataBinder.Eval (Container.Data Item,
"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
3106
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. However, the DataGrid begins to get very cumbersome as the number of columns of data you present increases. Anything more than half a dozen columns or so and you probably induce horizontal scrolling - a real no-no for me. If you put such a...
2
5597
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 the distance between these 2 columns. Is this possible? And by the way, I find it a little difficult to control the spacing and alignment of template items (cells). For examle the right cell/column is a little lower than the left one.
0
1580
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 in what looks as an attempt to Justify them. Item Horizonal Alignment is set to Left, HorizontalAlign is set to left also. But it does not display them both aligned to the left. Thanks
1
2566
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 when the user is looking at the data, the columns move back and forth among the DataLists. I don't know how well this will appear in text, but it looks something like: XXX XXXXX XXXXX XXX XXXX XXXXX
3
1963
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, but the RescheduledFromDate does. In general, only a GigDate will be supplied, but if a Gig is rescheduled, the GigDate is copied to RescheduledFromDate, and the GigDate then becomes the "new" date. I'm using a DataList instead of a Grid because...
0
1063
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 in what looks as an attempt to Justify them. Item Horizonal Alignment is set to Left, HorizontalAlign is set to left also. But it does not display them both aligned to the left. Thanks
5
4765
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 name="txtPass" value='<%#DataBinder.Eval(Container.DataItem,"Passwd")%>'></td> <td width="45%" align="left">
4
7807
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, there is another DB column named 'Description'. Though the resultset fetches this column as well along with the above 3 columns, I am excluding the Description column from the DataList - the reason being most of the descriptions are pretty long &...
1
1881
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 recessed it in a <Div></Divto allow scrolling of just the data, not the page. What I need to do is place a DataList (also in a <Div></Divto allow scrolling of just the data) to the right of the Datagrid to show 40 Employee Detail fields (listed top to...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9169
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7738
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.