473,748 Members | 6,664 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 3787
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
3114
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
5605
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
1583
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
2569
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
1965
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
1068
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
4768
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
7810
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
1884
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
8826
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
9366
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9241
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8239
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...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
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
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.