Dynamic generation of a table

  • Thread starter Thread starter K Viltersten
  • Start date Start date
K

K Viltersten

In my asp:Repeater, i'm starting a mark-up
for a table in the <HeaderTemplate> and
finish it up in the <FooterTemplate>.
However, i'd like to dynamically create it
and i wonder how i can do so.

How can i produce "a half" of HtmlTable?
Or should i rather aim for dynamically
creating the whole asp:Repeater part? How
can i do that wisely (i.e. smoothly)?
 
In my asp:Repeater, i'm starting a mark-up
for a table in the <HeaderTemplate> and
finish it up in the <FooterTemplate>.
However, i'd like to dynamically create it
and i wonder how i can do so.

How can i produce "a half" of HtmlTable?
Or should i rather aim for dynamically
creating the whole asp:Repeater part? How
can i do that wisely (i.e. smoothly)?

--
Regards
K Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.

Why don't you use <asp:table> then? Or a gridview?
 
I'm not sure how that helps. Please elaborate.

--

Regards
Konrad Viltersten
--------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.

Hi Konrad,

ASP.NET has few other controls to generate tables - GridView and Table

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.table.aspx
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx

So, instead of modifying a list from Repeater, you can build a table
using GridView, or Table controls.

If for any reason you need to have a Repeater, do following:

<%@ Import Namespace="System.Data" %>

<asp:Repeater id="cdcatalog" runat="server">

<HeaderTemplate>
<table border="1" width="100%">
<tr>
<th>Title</th>
<th>Artist</th>
<th>Company</th>
<th>Price</th>
</tr>
</HeaderTemplate>

<ItemTemplate>
<tr>
<td><%#Container.DataItem("title")%> </td>
<td><%#Container.DataItem("artist")%> </td>
<td><%#Container.DataItem("company")%> </td>
<td><%#Container.DataItem("price")%> </td>
</tr>
</ItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>

</asp:Repeater>

Hope this helps
 
ASP.NET has few other controls to generate
tables - GridView and Table
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.table.aspx
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx
So, instead of modifying a list from
Repeater, you can build a table using
GridView, or Table controls.
If for any reason you need to have a Repeater,
do following:
<%@ Import Namespace="System.Data" %>
<asp:Repeater id="cdcatalog" runat="server">
<HeaderTemplate>
<table border="1" width="100%">
<tr>
<snip>

I'd need to change the style of the table
dynamically, from code behind. In order to
do so, i need to run it on server BUT then
i get problems because when run on server,
the control/element (table) musn't span
accross multiple templates... Sight... :(

Suggestions?
(Yes, i'm required to use asp:Repeater.)
 
<snip>

I'd need to change the style of the table
dynamically, from code behind. In order to
do so, i need to run it on server BUT then
i get problems because when run on server,
the control/element (table) musn't span
accross multiple templates... Sight... :(

Suggestions?
(Yes, i'm required to use asp:Repeater.)

--
Regards
K Viltersten
----------------------------------------
May all spammers die an agonizing death;
have no burial places; their souls be
chased by demons in Gehenna from one room
to another for all eternity and beyond.

<HeaderTemplate>
<table style="<%=TableStyle%>">
</HeaderTemplate>
 
Back
Top