Problem with ASP DataList control [was 'Aligning without tables/cells']

liunx

Guest
I am trying to use a server side control (ASP.NET, DataList) to bind and view data.
In terms of presentation, I am stuck.

I can create an ItemTemplate (which is basically the info about the data itself and its presentation) but within it, I am creating a table with several rows and several cells per row. Thats fine BUT I want to get rid of the gap that is created between each records shown, since each record is within a table.

Is there a way I can avoid using a table but still keep the data aligned neatly in each column?

Does this make sense?this is a first... someone who doesn't want to use tables for what they were actually intended for :P

tables are a little tricky, because even though you carefully set things up in CSS to remove all margins and padding, you still get an annoying gap in most browsers...
this is because there are two attributes for tables which are not included in CSS - cellpadding and cellspacing...

so, you CSS should include:

table
{
border-collapse: collapse;
border-spacing: 0;
}

td, th
{
margin : 0;
padding : 0;
}

and you table element in HTML:

<table cellpadding='0' cellspacing='0'>
</table>


et voila... a properly collapsed table, instead of the default model from the browser...thanks, that didnt work :(
sure I will use tables if its the correct manner but just letting you know, if you havent dealt with the DataList control before that everytime the row is created, it will create a new table per row.... :) since that is the "template" for each row.

cant quite get this to work in CSS. firstly:

1) am I able to name the classes differently so that when I put in the cssclass= in the table, I can tell it which class to look at and use? how can I do this?

can you give me an example of using a table and telling it which cssclass to use? (Sorry, totally new to CSS)this is looking like a problem with the ASP control rather than HMTL/CSS - its pretty poor that the control is creating a new table for each row... but I'm afraid I'm not an ASP expert...

I'll move your thread to there so that someone who is can help you...You can use the BorderWidth and CellSpacing & CellPadding properties.... but i would use a DataGrid if you are going to be displaying tabular data....thanks for moving it to the right place, its much appreciated.
ill try it with a datagrid and see what happens :)

any advice on how to go about achieving this correctly using the DataGrid?

I am now using the DataGrid so trying to reformat the heading and the grid itself. Problem is I have a header image but I also want to show some text in the header cell/bound column. But it the image is overriding the headertext. What can be done?actually I think ive done it! Thanks for that, now using the DataGrid!
 
Back
Top