473,386 Members | 1,943 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,386 software developers and data experts.

Loop to display nested items in Repeater control?

Hi everyone :-)

I am learning to use the Repeater control to display a list of data.
Each of my list items (or rows, however you look at it) has some child
items that are 1..N in length. So I'd like to be able to - within the
Repeater's ItemTemplate - loop over those child elements and display
some controls for each.

Right now I'm simply trying to do a loop (e.g. <% For Each stuff as
String in Eval("Things") ... Next %>, but that does not work. And I
don't believe that's what Eval is meant for (item retrieval). Anyway,
the error it gives is: "Databinding methods such as Eval(), XPath(),
and Bind() can only be used in the context of a databound control."

How do I go about doing this?

Thanks,
Sean

Mar 8 '07 #1
4 9647
xke
Hi Sean,

Not sure if this is what you are looking for, have a look and let me
know.

http://www.codeproject.com/aspnet/As...dRepeaters.asp

Xke
On Mar 8, 4:46 pm, "parsifal" <sean.gilbert...@gmail.comwrote:
Hi everyone :-)

I am learning to use the Repeater control to display a list of data.
Each of my list items (or rows, however you look at it) has some child
items that are 1..N in length. So I'd like to be able to - within the
Repeater's ItemTemplate - loop over those child elements and display
some controls for each.

Right now I'm simply trying to do a loop (e.g. <% For Each stuff as
String in Eval("Things") ... Next %>, but that does not work. And I
don't believe that's what Eval is meant for (item retrieval). Anyway,
the error it gives is: "Databinding methods such as Eval(), XPath(),
and Bind() can only be used in the context of a databound control."

How do I go about doing this?

Thanks,
Sean

Mar 8 '07 #2
the error it gives is: "Databinding methods such as Eval(), XPath(),
and Bind() can only be used in the context of a databound control."
It is saying Eval, XPath or Bind can only be used in dynamic
assignment (i.e <%# %>) of property of a data-bindable control, which
is different than a <% %block.

And contents of <%# %must evaluate to an object of type convertible
to property being assigned. Conditional or looping statements do not
evaluate to objects.

Nested repeater may be one way to go if appropriate.
If it is simply repeating or transforming something, try following.

<asp:Literal runat="server" id="ltlSomeLiteral"
EnableViewState="false" Text="<%# SomeFunction( Eval("Thing")) %>' />

with code behind

protected string SomeFunction(TypeOfThings input)
{
string ouput = string.Empty;
foreach(string stuff in input) // presuming input is IEnumberable
{
.....
}
return output;
}

Mar 9 '07 #3
On Mar 8, 4:00 pm, "xke" <xke...@gmail.comwrote:
Hi Sean,

Not sure if this is what you are looking for, have a look and let me
know.

http://www.codeproject.com/aspnet/As...dRepeaters.asp

Xke

On Mar 8, 4:46 pm, "parsifal" <sean.gilbert...@gmail.comwrote:
Hi everyone :-)
I am learning to use the Repeater control to display a list of data.
Each of my list items (or rows, however you look at it) has some child
items that are 1..N in length. So I'd like to be able to - within the
Repeater's ItemTemplate - loop over those child elements and display
some controls for each.
Right now I'm simply trying to do a loop (e.g. <% For Each stuff as
String in Eval("Things") ... Next %>, but that does not work. And I
don't believe that's what Eval is meant for (item retrieval). Anyway,
the error it gives is: "Databinding methods such as Eval(), XPath(),
and Bind() can only be used in the context of a databound control."
How do I go about doing this?
Thanks,
Sean- Hide quoted text -

- Show quoted text -
Hi!

Yes this is getting at exactly what I want. Thank you! :-) I also
found this article from Microsoft:

http://support.microsoft.com/kb/306154

Thanks again!
Sean :-)

Mar 9 '07 #4
xke
good to hear that

Mar 9 '07 #5

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

Similar topics

4
by: Ryan Ternier | last post by:
Thanks for the previous help guys! I got my list box issue working, but now i'm trying to loop through all the items in my page. I want to find each listbox, once I do i strip the ID down to...
2
by: Colin Nicholls | last post by:
Platform: ASP.NET 1.1 I have a repeater nested inside another repeater. My outer repeater is looping fine. I am manually binding the inner repeater to a DataReader obtained from another...
1
by: Maziar Aflatoun | last post by:
Hi, I have tried setting up a nested repeater control and it works fine. But when I do 3 level nested repeater it fails. Does anyone know a site or have an example of a three level nestest...
1
by: Taymorza | last post by:
All, I need some help with the ASP.NET Repeater Control. I am not a very strong ASP.NET developer. I am using the repeater control display pictures. I want to have six pictures in a row and then...
1
by: Dave | last post by:
I have a button in the same page as the repeter control, so when I click that I need to loop threw the repeater and get the value of each textbox and id Dave
1
by: Charlie | last post by:
Hi: I'm laying out a hieraracical report by nesting repeater controls. I'm using panels to expand/collapse detail sections. To access a panel in a nested repeater, I use the following code. ...
1
by: humbleFunGuy | last post by:
What does nested controls mean in .Net? Any help is appreciated. Thanks, fanzi
2
by: sck10 | last post by:
Hello, I am calling a stored procedure to populate a Repeater Control. What I need to do is see if a name is in the list and if not, add it to the Repeater. Is there a way to reset the...
4
by: =?Utf-8?B?SmFtZXMgR2V1cnRz?= | last post by:
On my page, I have one repeater that contains a literal control and a nested repeater. The nested repeater contains a literal control. Both repeaters are databound with only one object (string). ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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
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
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.