Dynamic generation of a table

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)?
 
G

Guest

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?
 
G

Guest

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
 
K

K Viltersten

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.)
 
G

Guest

<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>
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top