DataList containing a Repeater

G

GD

I'm using a DataList and a Repeater (nested in the DataList) to display
a list of "Chapters" and "Documents" within the Chapters.

<asp:DataList ID="dlChapter" Runat="server" RepeatColumns="2"
RepeatDirection="Vertical" OnItemDataBound="dlChapter_OnItemDataBound">
<ItemTemplate>
<table>
<tr>
<td colspan="2"><%# DataBinder.Eval(Container.DataItem,
"ChapterName")%></td>
</tr>
<tr
<td>Updated</td>
<td>Document Title</td>
</tr>
<asp:Repeater ID="rptDocument" Runat="server">
<ItemTemplate>
<tr>
<td><%#
((DataRow)Container.DataItem)["LastUpdatedOn_Formatted"]%></td>
<td><%# ((DataRow)Container.DataItem)["DocumentTitle"]%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</ItemTemplate>
</asp:DataList>

I'm using the DataList's OnItemDataBound to populate the Repeater with
the current DataRow's ChildRows. Works like a charm.

However, I'm having some display issues ... Because the RepeatColumns
property is set to two, the resulting HTML is a Table with two <td>'s
in each <tr>. However, the height of the content in each <td> isn't
necessarily the same as that of the content in the other <td> in that
<tr>

It seems as if RepeatLayout="Flow" would solve this problem, but
setting that seems to cause the DataList to ignore the
RepeatColumns="2" when rendering the HTML.

I scoured the groups for a solution to this :) Would appreciate any
tips!

Thanks!
 
P

Patrick.O.Ige

Have tried getting to cells and assigning them UNITS
Not sure of Datalist but sure i did that once with DataGrid
Hope that helps
Patrick
 
R

Rote Rote

You can do it at runtime e.g
Private Sub DataGrid1_ItemCreated(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles DataGrid1.ItemCreated
e.Item.Cells(0).Width = New Unit(100)
e.Item.Cells(1).Width = New Unit(50)
End Sub

or using the style element (or the ItemStyle-Height property). in
design

Hope that helps
Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top