473,387 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Iteraiting through repeater

Hi there,

I have a repeater that returns x rows from a main table.

I need to display some info stored on a secondary table that is linked to
the main using a one-to-many relationship.

Instead of using a nested repeater, I would like to manually do some checks
and display (or not) info contained on the secondary table.

Apparently the code to do this would be something like:

While objDataReader.Read()

'Do my checks and write whatever is needed

End While

Now if I place this code within the cell where the output is supposed to be
written (within the repeater), it returns nothing.

Am I doing something wrong? Is there a better way to do this?.

Thanks,

Marc


Feb 20 '06 #1
4 3527
Marc,

You should use either ItemDataBound or PreRender event. In the ItemDataBound
event you get access to every item as it gets values from the database.
Based on this value, you can look into another table and modify the item
content. In the PreRender event all items are already fully built and you
can loop through them doing the same look up.

You should get the data from the second table inside a DataTable and look up
there, or, better use DataRelation class to link two tables.

Eliyahu
"Marc Llenas" <ml*****@randagroup.es> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi there,

I have a repeater that returns x rows from a main table.

I need to display some info stored on a secondary table that is linked to
the main using a one-to-many relationship.

Instead of using a nested repeater, I would like to manually do some
checks and display (or not) info contained on the secondary table.

Apparently the code to do this would be something like:

While objDataReader.Read()

'Do my checks and write whatever is needed

End While

Now if I place this code within the cell where the output is supposed to
be written (within the repeater), it returns nothing.

Am I doing something wrong? Is there a better way to do this?.

Thanks,

Marc

Feb 20 '06 #2
Thanks Eliyahu,
I implemented the ItemDataBound approach as you recommended.

Now, how do I retrieve a value from the repeater? I need to get the value of
an ID field on the repeater in order to use it as a filter for a query
against the DB.

I've tried storing that value on a hidden field and then retrieving the
field's value but doesn't work (returns nothing). Any ideas on how to solve
this?

Thanks and have a great weekend.

Marc
"Eliyahu Goldin" <re*************@monarchmed.com> escribió en el mensaje
news:ea*************@TK2MSFTNGP14.phx.gbl...
Marc,

You should use either ItemDataBound or PreRender event. In the
ItemDataBound event you get access to every item as it gets values from
the database. Based on this value, you can look into another table and
modify the item content. In the PreRender event all items are already
fully built and you can loop through them doing the same look up.

You should get the data from the second table inside a DataTable and look
up there, or, better use DataRelation class to link two tables.

Eliyahu
"Marc Llenas" <ml*****@randagroup.es> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi there,

I have a repeater that returns x rows from a main table.

I need to display some info stored on a secondary table that is linked to
the main using a one-to-many relationship.

Instead of using a nested repeater, I would like to manually do some
checks and display (or not) info contained on the secondary table.

Apparently the code to do this would be something like:

While objDataReader.Read()

'Do my checks and write whatever is needed

End While

Now if I place this code within the cell where the output is supposed to
be written (within the repeater), it returns nothing.

Am I doing something wrong? Is there a better way to do this?.

Thanks,

Marc


Feb 24 '06 #3
This should do what you want I think.

foreach (RepeaterItem dataItem in rptCart.Items)
{
CheckBox ckDelete =
(CheckBox)dataItem.FindControl("ckDel1");
TextBox txtLineNumber =
(TextBox)dataItem.FindControl("txtLineNumber");
TextBox txtQuantity =
(TextBox)dataItem.FindControl("txtQty");
int linenbr = int.Parse(txtLineNumber.Text);
if (ckDelete.Checked)
{
//delete the item
}
else
{
//update the item
}
}

Chris

Feb 25 '06 #4
Thanks Chris, that pointed me to the right direction.

Cheers,

Marc

"chris" <ch***@cubed-c.com> escribió en el mensaje
news:11**********************@v46g2000cwv.googlegr oups.com...
This should do what you want I think.

foreach (RepeaterItem dataItem in rptCart.Items)
{
CheckBox ckDelete =
(CheckBox)dataItem.FindControl("ckDel1");
TextBox txtLineNumber =
(TextBox)dataItem.FindControl("txtLineNumber");
TextBox txtQuantity =
(TextBox)dataItem.FindControl("txtQty");
int linenbr = int.Parse(txtLineNumber.Text);
if (ckDelete.Checked)
{
//delete the item
}
else
{
//update the item
}
}

Chris

Feb 28 '06 #5

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

Similar topics

0
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
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...
0
by: Amir | last post by:
Hi every one This is the problem: I have a UserControl that contains a Repeater and a few LinkButton. The Repeater generate some linkButton. I use this control for implementing paging solution...
3
by: sorCrer | last post by:
Hi All, Posted after extensive searching! I have a nested repeater control as follows: (Simplified ;-)) <table> <asp:repeater id=parent onItemDataBound=createChild> <tr><td>Level...
8
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">...
1
by: olduncleamos | last post by:
Hello all, I am experimenting with the repeater control and ran into something that I wasn't expecting. I would appreciate if the experts can confirm or correct my understanding. Here is a...
2
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
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...
0
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.