Datalist Formatting Strangeness

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

Hey,

Can anyone out there see why when this code renders there's a 1px space
between the headertemplate and the itemtemplate.

<asp:datalist id="asplistDL" BorderStyle="None" RepeatLayout="table"
cellspacing="0" cellpadding="0" runat="server" horizontalalign="center"
width="100%" borderwidth="0">
<headertemplate>
<table width="100%" cellpadding=0 cellspacing=0>
<tr>
<th class="loggedinheader">
Administrator</th>
<th height="100%" class="loggedinheader">
Email</th>
<th class="loggedinheader">
Phone</th>
<th class="loggedinheader">
Active</th>
<th></th>
</tr>
</headertemplate>
<ItemTemplate>
<tr>
<td valign="top" height="100%"
class="sitesum">
<%# DataBinder.Eval(Container.DataItem,
"firstname")%> <%# DataBinder.Eval(Container.DataItem, "Surname")%>
</td>
<td height="100%" valign="top"
class="sitesum">
<a href="mailto:<%#
DataBinder.Eval(Container.DataItem, "email")%>"> <%#
DataBinder.Eval(Container.DataItem, "email")%> </a>
</td>
<td height="100%" valign="top"
class="sitesum">
<table>
<tr>
<td class="paragraph_heading">
Day Phone:
</td>
<td class="paragraph_text">
<%#
DataBinder.Eval(Container.DataItem, "day_phone")%>
</td>
</tr>
<tr>
<td class="paragraph_heading">
Evening Phone:
</td>
<td class="paragraph_text">
<%#
DataBinder.Eval(Container.DataItem, "eve_phone")%>
</td>
</tr>
<tr>
<td class="paragraph_heading">
Mobile:
</td>
<td class="paragraph_text">
<%#
DataBinder.Eval(Container.DataItem, "mobile")%>
</td>
</tr>
</table>
</td>
<td height="100%" valign="top"
class="sitesum">
<%#
cusCls.webdingit(cusCls.yesno(DataBinder.Eval(Container.DataItem,
"active")))
%>
</td>
<td align="center" class="sitesum">
<a href="adminupdate.aspx?uid=<%#
DataBinder.Eval(Container.DataItem, "user_id")%>">View/Update</a>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
<td valign="top" height="100%"
class="alt_sitesum">
<%# DataBinder.Eval(Container.DataItem,
"firstname")%> <%# DataBinder.Eval(Container.DataItem, "Surname")%>
</td>
<td height="100%" valign="top"
class="alt_sitesum">
<a href="mailto:<%#
DataBinder.Eval(Container.DataItem, "email")%>"> <%#
DataBinder.Eval(Container.DataItem, "email")%> </a>
</td>
<td height="100%" valign="top"
class="alt_sitesum">
<table>
<tr>
<td class="paragraph_heading">
Day Phone:
</td>
<td class="paragraph_text">
<%#
DataBinder.Eval(Container.DataItem, "day_phone")%>
</td>
</tr>
<tr>
<td class="paragraph_heading">
Evening Phone:
</td>
<td class="paragraph_text">
<%#
DataBinder.Eval(Container.DataItem, "eve_phone")%>
</td>
</tr>
<tr>
<td class="paragraph_heading">
Mobile:
</td>
<td class="paragraph_text">
<%#
DataBinder.Eval(Container.DataItem, "mobile")%>
</td>
</tr>
</table>
</td>
<td height="100%" valign="top"
class="alt_sitesum">
<%#
cusCls.webdingit(cusCls.yesno(DataBinder.Eval(Container.DataItem,
"active")))
%>
</td>
<td align="center" class="alt_sitesum">
<a href="adminupdate.aspx?uid=<%#
DataBinder.Eval(Container.DataItem, "user_id")%>">View/Update</a></td>
</tr>
</AlternatingItemTemplate>
<footertemplate>
</table>
</footertemplate>

</asp:datalist>

Thanks


Joe
 
DataList renders all it's items in a table. That means in additional to the
table you have, there another one where everythihng actually is (check the
HTML rendered).

If you don't want the control to do this table type formatting for you, try
a Repeater control. I believe this just repeats the template for each
element exactly, without placing them all in a table for you.
 
Thanks Marina,

Actually I did have a look at the html output in the interim and discovered
the surrounding table myself - it seems to be a little flakey in the way
it's implemented as it puts an extra blank cell at the end of each item
which is causing the gap.

I considered using the repeater and it would be fine in this case but there
will be other instances where I will want to do sorting and editing and I
believe that's a lot of work with a repeater control - hmmmm, it's friday, I
don't like the sound of that.

I also considered the datagrid to achieve the formatting I want I would
loose my alternating item template and I also want to stick with CSS - not
the style properties exposed by all of these controls.

I suspect that I could find a solution if I were a little more adept with
CSS and tables as there is a cssclass property - hmmmm, I'll have to think
about that one....

In the meantime if anyone else has encountered this issue (and I can't
believe nobody but me has) I'd be grateful for some direction.

Joe
 
Actually, just found a way to hide it with CSS - that will do for now -
onward and downward....
 
Back
Top