Linq and nested repeaters

I'm a total noob to .NET, ASP.NET, LINQ and so on, so please be gentle. :-)

I'm trying to display a list of people and the tags that are on those people, something like this:

Gabriel - this, that, these, those
John - that, those, another
Sarah - that, another, something

I'm using Linq to access the data, and can get the list of people going with this code:

1    var peoplelist = from p in thing.People
2 select new {
3 p.FullName
4 };
6 PeopleRepeater.DataSource = peoplelist;
7 PeopleRepeater.DataBind();
 Now, I have a m->m link between people and tags, and use code like this to display the tags on a single person:
1    var taglist = (from tag in db.Tags
2 join persontag in db.PeopleTags on equals persontag.TagID
3 where persontag.PersonID == person.PersonID
4 orderby tag.TagName
5 select tag);
7 ViewTagRepeater.DataSource = taglist;
8 ViewTagRepeater.DataBind();
I can't for the life of me figure out how to get these to play nicely together using nested repeaters. If I move the ViewTagRepeater into the PeopleRepeater.ItemTemplate, and adjust the query to relate to peoplelist somehow, will everything just kind of work together?
1/22/2008 4:06:19 AM 72751 articles. 3 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 46


Assuming your object is called Person, your linked tags is called Tags and a tag has a TagName maybe something like this:

var peoplelist = from p in thing.People select p;

// Bind this to repeater which looks like so:

 <asp:Repeater ID="rptPeople" runat="server">
        <%# Eval("FullName") %>
        <asp:Repeater id="rptTags" runat="server" DataSource="<%# ((Person)Container.DataItem).Tags  %>">
                <%# Eval("TagName") %>
        <br /><br />

So basically you select a person who has a link to their tags which are bound in the nested repeater.

You could also do load options so that your tags are not lazy loaded and only use 2 sql queries instead of 1 X nopeople queries, you would do this on you datacontext assuming it is called db something like so:

            System.Data.Linq.DataLoadOptions opts = new System.Data.Linq.DataLoadOptions();
            opts.LoadWith<Person>(item => item.Tags);
            db.LoadOptions = opts;

Hope that helps.


1/22/2008 7:38:38 AM

Thanks Stefan, that helped a lot. In the end I used Mitsu's technique to bring the M->M Tags link into the Person class, then used your technique to hook up the repeater.

Thanks again,


1/22/2008 4:39:19 PM

Hi GabrielX,

I am trying to do the same thing now with Nested Repeaters and using Linq, pretty much the same way as you.  Except in my case, Discography (i.e. lists of CDs) is the main table and Tracks is a subtable: a One-to-Many relationship between Discography and Tracks.

So I was wondering if you could show me your final code or you could explain how you solved this one, as I am struggling to bind data to my inner Repeater.

Many thanks,



4/23/2008 11:58:34 AM

Similar Artilces:

nesting a datalist control in a repeater control
Hi I need to display a report in the following format: Heading1 item one for heading1 item two for heading1 item three for heading1 ..... Heading2 item one for heading2 item two for heading2 item three for heading2 .... Heading3 item one for heading3 item two for heading3 item three for heading3 ..... I have tried use a repeater control for displaying the Headings and a datalist control to display the items for each heading. The problem is that I couldn't nest a datalist control between the repeater's ItemTemplate tag. Any help for nesting A...

Nested repeater controls in web custom control
Hi.  I've been reading up as much as I can about web custom controls, but think I may be reading myself in circles now.  I am interested in taking some nested repeaters (2) out of a UserControl and placing them inside of a web custom control.  I am getting confused about just how this would be implemented.  Do I need to inherit from Repeater, make a composite control, etc.  I am not interested in changing any functionality of the repeaters.  I have been tasked with this because the UserControl version has been giving our Sharepoint developer fits. Here is t...

ObjectDatasource with Repeater Control and Nested Repeats on Join
I have two tables (more but this will keep it simple) faq_parent_categories has (ID, Title,Description) faq_categories has (ID, Parent_ID, Title, Description) I'm joining the child Parent_ID to  the ID on the Parent table. I have a typed dataset with a method calleed getCategoriesByParentID(@parent_id) My select is pretty simple SELECT, b.descriptionFROM     faq_parent_categories AS a, faq_categories AS b  WHERE a.ID = b.parent_id AND a.ID = @parent_id In my repeater I want to first get the Parent Category and have it as a <h1> then...

Problem with find controls in a child repeater (Nested Repeater)
I'm pretty new to ASP .Net, and have been strugling with this problem for the past few days. Is there anyone knows how to find a control in the child repeater as the given example? Thanks. 1 <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"> 2 <ItemTemplate> 3 <ul> 4 <li> 5 <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource1"> 6 <ItemTemplate> 7 <ul> 8 <li> &...

Binding Repeater and Nested Repeater using Linq To Sql
Can anyone tell me how to bind a repeater and nested repeater using Linq To Sql? If possible, can you give an example in VB. Thanks Start looking at: Video:How Do I? With LINQRegards,Vinz"Code, Beer and Music" that's my way of being a programmer!How to get your Forum Question Answered | Blog | CodeASP.NET...

Repeater control in another repeater control
Hi, I want Repeater control in another repeater control but it is not working Code : <asp:Repeater ID=CourseMaster Runat=server > <ItemTemplate> <table border=0 cellpadding=0 cellspacing=0 style="font-family:tahoma;font-size:12"> <tr> <td >&nbsp;<b</b></td> </tr> <tr> <td> <asp:repeater ID="CourseDetails" Runat=server> <ItemTemplate> <tab...

nested data grid with repeater control and reading repeater values
Hi, I have problem in reading values in nested datagrid with repeater control. I have check box and value dropdown list control and I want to read users input in nested repeater control but I am getting null reference error when i am doing this. Anyone help me in this regards. below is my code. <asp:datagrid id="Rdg" runat="server">     <Columns><asp:TemplateColumn ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign="Top">     <ItemTemplate>     <asp:Label id="lblid" runat="server" Visible="false" text...

Nested Listview Controls using LINQ but adding a filter to the child control
It's the usual Categories and Items belonging to those categories I am trying to display. Items as a list/tablerows under the heading text of the category. I had it working perfectly by having a single Linqdatasource as the source for the parent Listview. I could then access the 'child' items by simply referencing the columns from the sub class in the dbml which has an association in it. Brilliant, zero code and clean UI. The problem is I want to apply a filter to the sub-items so that only items marked active (a bool column) are shown. I have gone round in ...

accordion nested in a repeater error -- need to find control in repeater first, then?
short version   ASPX>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> &lt;repeater1 OnItemDataBound="Repeater1_DataBound"&gt; <item>Some stuff here<%#Eval("foofoo")%> 'this comes from databound dataset - this works <ajaxToolkit:Accordion ID="Accordion1" runat="server" TransitionDuration="100" FramesPerSecond="200" FadeTransitions="true" RequireOpene...

LINQ and Nested Repeaters
Hi folks.I have earlier wrapped data into a nested repeater by using ((DataRowView)e.Item.DataItem).CreateChildView("MenuItemRelations"); Now I'm trying to use LINQ instead to build lists, but i'm not sure how to connect the nested repeater.  By now I have a List<myMenuClass> to hold all menues and inside the myMenuClass, I have a new SortedList<int,myMenuItemClass>I have set the RepeaterLeftMenu.DataSource = lstMenuIn the RepeaterLeftMenu_ItemDataBound i'm trying to bind the nested repeater to the SortedList inside the outer list. Please help...

Nested Repeater control
Hi, I am using Nested Repeater controls in my web page. Outer Repeater control contains Link Button (which will display the Category Names through data binding) and a Repeater control(this is inner repeater control which contains another Link Button to display Sub Category Names). Now i want to redirect to another page when user click the Inner Repeater control's Link Button .... Can any body tell me how to do this. Thank youChinna_sv... If you want to redirect why are you using a LinkButton and not the HyperLink?If you have a good reason to use the LinkButton you will have to ...

Nesting Repeater Controls
I am trying to follow a tuotial (located here:;EN-US;306154) but I get the following error when browsing the page: Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 32: Line 33: //Create the relation...

Nested Repeater Controls
I'm trying to do a nested Repeater where I have two tables, one is my region and second is the projects table. There's a foreign key in the projects table for region. I am doing an inner join in my stored procedure and I need the data to be displayed like this: Region 1 strDate strTitle strContent strDate strTitle strContent strDate strTitle strContent Region 2 strDate strTitle strContent strDate strTitle strContent strDate strTitle strContent Region 3 strDate strTitle strContent st...

Nested repeater
I have a reapeater,  I want to use the value of a databound item to populate another repeater.  Can someone help: I want to use the value of lblJobNumber to call seperate functions to retrieve data and populate repImages, repImages, repOtherFile asp:Repeater ID="countDetailsRepeater" runat="server"> <ItemTemplate> <div class="cv_padded_div"> <div class="tms_header"> Count Details </div> <table class="cv_tbl"> <tr class="cv_row"> <td class="cv_rowLabel&qu...

Web resources about - Linq and nested repeaters -

Repeaters - Wikipedia, the free encyclopedia
Kyle Halsted, Sonia Logan, and Michael Weeks are inmates at a rehabilitation facility. Bob Simpson, the administrator, tasks them with apologizing ...

Animal Repeater Memory Game HD Free Lite - for iPad for iPad on the iTunes App Store
Get Animal Repeater Memory Game HD Free Lite - for iPad on the App Store. See screenshots and ratings, and read customer reviews.

Consumers warned to beware of illegal mobile phone repeaters
Use of devices sold online as legitimate solution is in fact dangerous and can land you in jail, regulator warns.

Grim repeater: HIV on the rise
CANDLES flicker in the chilly night air as Jesse Hooper appears on the giant cinema screen overlooking Melbourne&#8217;s Federation Square. He&#8217;s ...

Telstra suspects underbelly of illegal repeaters
'Tens' busted each year. Telstra engineers suspect a "vast" undercurrent of illegal repeaters are causing issues for the carrier's Next G mobile ...

Hands on: Cel-Fi mobile repeater
If your home is a mobile blackspot then a Cel-Fi mobile repeater might help you stay connected.

Amped Wireless R20000G, SR20000G, and UA2000: Routers, Repeaters, and Adapters
... and throughput when pointed at your wireless router/access point. Rounding out the review, Amped sent a third product, their SR20000G repeater, ...

Photon heralds entanglement in new quantum repeater
... For ordinary electrical wires (such those used for ethernet), signals can travel long distances because they're boosted by means of repeaters ...

Celebrity Rehab Repeaters
Kate Middleton Bikini Photos 50 Shades of Grey Hollywood Couples Red Carpet The Kardashians Best Dressed Hot Bodies Celebrity Kids News Sightings ...

Computer networking: wireless networks (wifi), routers, repeaters & more - CNET Reviews
Computer networking reviews and ratings, video reviews, user opinions, most popular network hardware, wireless network buying guides, prices, ...

Resources last updated: 11/24/2015 3:55:34 AM