473,498 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add new row to Repeater?

I am having issues adding a new row in my repeater when my repeater's
table cells reach a certain number. what i'm doing is adding a
predetermined number of color cells from the database and bringing them
into a repeater that is located already inside a table cell which
cannot exceed a certain width.

for example:

ASP:
------------------------------------
<asp:Repeater ID="Repeater1" runat="server"
OnItemDataBound="Repeater1_ItemDataBound">

<HeaderTemplate>
<table id="uiColorTable"><tr>
</HeaderTemplate>

<ItemTemplate>
<td>
<asp:Panel ID="uiColorSwatch" runat="server" Height="10px"
HorizontalAlign="Center" Width="50px" BackColor='<%#
DataBinder.Eval(Container.DataItem , "ArgbColor") %>'></asp:Panel>
<asp:Label ID="uiColorName" CssClass="uiColorName" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>'></asp:Label>
</td>
</ItemTemplate>

<SeparatorTemplate>
<td>&nbsp;&nbsp;</td>
</SeparatorTemplate>

<FooterTemplate>
</tr></table>
</FooterTemplate>

</asp:Repeater>

C#:
--------------------------------
protected void Repeater1_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
int x = 0;
foreach (RepeaterItem tmpItem in Repeater1.Items)
{
if (x == 8)
{
LiteralControl tmpLiteral = new
LiteralControl("</td></tr><tr><td>");
Repeater1.Controls.Add(tmpLiteral);
x = 0;
}
else
{
x++;
}
}
}

to be honest, i have a feeling i'm not doing something retardedly
simple but after staring at this for a few hours, i'm starting to get
crosseyed. some help would be awesome!

Sep 23 '06 #1
2 18336
Maybe you can clarify, because I don't quite see where the problem is.

If you want to display a specific number of columns, I would use a
datalist control like so:

<asp:DataList ID="DataList" Width="100%" runat="server"
ItemStyle-HorizontalAlign="Center" RepeatColumns="5"
RepeatDirection="Horizontal">

It's much easier than outputting the html yourself. I try to let
asp.net generate as much html as possible, because otherwise you have
to keep track of td and tr, and it can get cumbersome.

Is there a specific reason your using a repeater control?

hope that helps!

Sean

Steve wrote:
I am having issues adding a new row in my repeater when my repeater's
table cells reach a certain number. what i'm doing is adding a
predetermined number of color cells from the database and bringing them
into a repeater that is located already inside a table cell which
cannot exceed a certain width.

for example:

ASP:
------------------------------------
<asp:Repeater ID="Repeater1" runat="server"
OnItemDataBound="Repeater1_ItemDataBound">

<HeaderTemplate>
<table id="uiColorTable"><tr>
</HeaderTemplate>

<ItemTemplate>
<td>
<asp:Panel ID="uiColorSwatch" runat="server" Height="10px"
HorizontalAlign="Center" Width="50px" BackColor='<%#
DataBinder.Eval(Container.DataItem , "ArgbColor") %>'></asp:Panel>
<asp:Label ID="uiColorName" CssClass="uiColorName" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>'></asp:Label>
</td>
</ItemTemplate>

<SeparatorTemplate>
<td>&nbsp;&nbsp;</td>
</SeparatorTemplate>

<FooterTemplate>
</tr></table>
</FooterTemplate>

</asp:Repeater>

C#:
--------------------------------
protected void Repeater1_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
int x = 0;
foreach (RepeaterItem tmpItem in Repeater1.Items)
{
if (x == 8)
{
LiteralControl tmpLiteral = new
LiteralControl("</td></tr><tr><td>");
Repeater1.Controls.Add(tmpLiteral);
x = 0;
}
else
{
x++;
}
}
}

to be honest, i have a feeling i'm not doing something retardedly
simple but after staring at this for a few hours, i'm starting to get
crosseyed. some help would be awesome!
Sep 23 '06 #2
If you want to display a specific number of columns, I would use a
datalist control like so:

<asp:DataList ID="DataList" Width="100%" runat="server"
ItemStyle-HorizontalAlign="Center" RepeatColumns="5"
RepeatDirection="Horizontal">

It's much easier than outputting the html yourself. I try to let
asp.net generate as much html as possible, because otherwise you have
to keep track of td and tr, and it can get cumbersome.

Is there a specific reason your using a repeater control?

hope that helps!

Sean

Steve wrote:
I am having issues adding a new row in my repeater when my repeater's
table cells reach a certain number. what i'm doing is adding a
predetermined number of color cells from the database and bringing them
into a repeater that is located already inside a table cell which
cannot exceed a certain width.

for example:

ASP:
------------------------------------
<asp:Repeater ID="Repeater1" runat="server"
OnItemDataBound="Repeater1_ItemDataBound">

<HeaderTemplate>
<table id="uiColorTable"><tr>
</HeaderTemplate>

<ItemTemplate>
<td>
<asp:Panel ID="uiColorSwatch" runat="server" Height="10px"
HorizontalAlign="Center" Width="50px" BackColor='<%#
DataBinder.Eval(Container.DataItem , "ArgbColor") %>'></asp:Panel>
<asp:Label ID="uiColorName" CssClass="uiColorName" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>'></asp:Label>
</td>
</ItemTemplate>

<SeparatorTemplate>
<td>&nbsp;&nbsp;</td>
</SeparatorTemplate>

<FooterTemplate>
</tr></table>
</FooterTemplate>

</asp:Repeater>

C#:
--------------------------------
protected void Repeater1_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
int x = 0;
foreach (RepeaterItem tmpItem in Repeater1.Items)
{
if (x == 8)
{
LiteralControl tmpLiteral = new
LiteralControl("</td></tr><tr><td>");
Repeater1.Controls.Add(tmpLiteral);
x = 0;
}
else
{
x++;
}
}
}

to be honest, i have a feeling i'm not doing something retardedly
simple but after staring at this for a few hours, i'm starting to get
crosseyed. some help would be awesome!
Sep 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5381
by: Ed Allan | last post by:
http://ejaconsulting.com/nestedrepeater/NestedRepeater.txt >-----Original Message----- >Doh! The HTML has all been rendered . . . > >Right click on this link and select 'Save target as ..' >to...
8
4262
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
8
2890
by: I am Sam | last post by:
Hi everyone, This problem is making me old. I don't want to get any older. I have a multi-nested repeater control as follows: <asp:Repeater ID="clubRep1" Runat="server">...
2
1894
by: mark | last post by:
(not sure if this is the correct group) My problem is I need to have a "nested" repeater. I have an array which I load into a hashtable - that part works great. I can setup the second repeater...
2
1901
by: GD | last post by:
I'd like to use a Repeater to display data coming back from a cross-tab report. Because it's a cross-tab, I generally don't know how many columns are coming back. They do follow a certain format: ...
8
3001
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
4
4883
by: Brad Baker | last post by:
I'm going a little crazy :) I'm trying to bind a repeater control to a dataset on page load using the following code: if (Request.QueryString != null) { string customerid = Request.QueryString;...
0
4080
by: uncensored | last post by:
Hello everyone, I'm fairly new at .Net and I have a repeater inside a repeater problem. I will attach my code to this message but basically what I am able to tell when I run my page it tells me...
7
2986
by: | last post by:
I have what's probably a simple page lifecycle question related to dynamically evaluating values that are placed by a repeater and dynmically placing user controls that use those values. I'm...
3
3931
by: Emma Middlebrook | last post by:
Hi there, I've been trying to implement a repeater control in an ASP.NET 2 page but I can't seem to get the layout exactly how I want and I'm not sure if it's something that I am doing wrong or...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7205
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.