repeater

repeater function

 

Indoor Coverage

 

Repeater Function
Range Repeater
Arrl Repeater
Repeater Row
Repeater Circuit
Amateur Radio Repeater
D Link Repeater

 

Repeater
Net Repeater
Amateur Repeater
Datagrid Repeater
Repeater Transmitter
Repeater Receiver
Repeater Button
Dsl Repeater
Repeater Function
Ir Repeater
Wireless Repeaters
Ham Repeaters
Usb Repeater
Ham Radio Repeaters
Firewire Repeater
Net Repeater Control
Gps Repeater
Henry Repeater
Airlink Repeater
Wireless G Repeater
Repeater Controllers
Wre54g Can Not Associate With This Ap In Repeater Mode
Repeater Itemcommand
Bluetooth Repeater
Repeater Software
Signal Repeaters
California Repeaters
Spring Air Repeater
Ethernet Repeaters

Cellular Repeater

Google
http://www.indoorcoverage.com/

Nesting Repeaters In .net
By ProgrammerTutorials.com, Fri Dec 9th

Data repeaters in .NET are very usefull to display databaserecords onto screen. But usually, in a real world situation, youdon't have enough functionality with 1repeater.

Take for example some kind of menu structure. You want todisplay a category, but every category can have 0 or moresubcategories. With 1 repeater, this cannot be done in a simpleway. In .NET, you can use nested repeaters for this.


Take the code below in the .aspx file:

... other HTML code ...
<asp:Repeater Runat="server"ID="Category">
<ItemTemplate>

    <ahref="category.aspx?category=<%#DataBinder.Eval(Container.DataItem, "Category") %>"><%#DataBinder.Eval(Container.DataItem, "Category")%></a><br>
</ItemTemplate>
</asp:Repeater>
... other HTML code ...



Here you will get a list of categories. If you want toadd subcategories, one could try to make the code below work.


... other HTML code ...
<asp:Repeater Runat="server"ID="Category">
<ItemTemplate>
    <ahref="category.aspx?category=<%#DataBinder.Eval(Container.DataItem, "Category") %>"><%#DataBinder.Eval(Container.DataItem, "Category")%></a><br>
    <asp:Repeater Runat="server"ID="SubCategory">
    <ItemTemplate>

        <ahref="category.aspx?category=<%#DataBinder.Eval(Container.DataItem, "SubCategory")%>"><%# DataBinder.Eval(Container.DataItem,"SubCategory") %></a><br>
    </ItemTemplate>
    </asp:Repeater>
</ItemTemplate>
</asp:Repeater>
...other HTML code ...



To make things work, you have to change several thingsthough.
In your .aspx.cs file (or in the script area ifyou are not using codebehind files) you will have the followingcode:



... other c# code ...
DataSet sqlDS = newDataSet();


/* Get the categories */
string Query = "selectCategoryId, Category from Categories order by Category";

SqlCommand sqlC = new SqlCommand(Query, objConn);
SqlDataAdapter sqlDA = new SqlDataAdapter();
sqlDA.SelectCommand = sqlC;


sqlDA.Fill(sqlDS, "Category"); /// Our dataset contains thecategories


/* Get the subcategories */
string Query = "selectSubCategoryId, CategoryId, SubCategory from SubCategories orderby SubCategory";
sqlC = new SqlCommand(Query, objConn);
sqlDA.SelectCommand = sqlC;


sqlDA.Fill(sqlDS,


"SubCategory"); /// Our dataset contains thecategories


/* Add a relationship between the 2 tables
In our case,every SubCategory has a CategoryId to pojnt out there parent
*/
ds.Relations.Add("CategoryRelation",ds.Tables["Category"].Columns["CategoryId"],ds.Tables["SubCategory"].Columns["CategoryId"]);


Category.DataBind();
... other c# code ...



In your .aspx file you will have to change the DataSourceto your child repeater (SubCategory) and the syntax in which youget the data.
The code below does so:


... other HTML code ...
<%@ ImportNamespace="System.Data" %>


<asp:Repeater Runat="server" ID="Category">
<ItemTemplate>
    <ahref="category.aspx?category=<%#DataBinder.Eval(Container.DataItem, "Category") %>"><%#DataBinder.Eval(Container.DataItem, "Category")%></a><br>

    <asp:Repeater Runat="server"ID="SubCategory" DataSource='<%#((DataRowView)Container.DataItem).Row.GetChildRows("CategoryRelation")%>>
    <ItemTemplate>
        <ahref="category.aspx?category=<%#DataBinder.Eval(Container.DataItem, "["SubCategory"]")%>"><%# DataBinder.Eval(Container.DataItem,"["SubCategory"]") %></a><br>
    </ItemTemplate>
    </asp:Repeater>
</ItemTemplate>

</asp:Repeater>
... other HTML code ...



If you do both changes, the code should work fine.



Another interesting thing to note is how you can access adataitem from the parent (from within your child).
Forexample, we wish the link to include the Category also, even ifit is a SubCategory.
Adjust your .aspx file to thefollowing:


... other HTML code ...
<%@ ImportNamespace="System.Data" %>


<asp:Repeater Runat="server" ID="Category">
<ItemTemplate>
    <ahref="category.aspx?category=<%#DataBinder.Eval(Container.DataItem, "Category") %>"><%#DataBinder.Eval(Container.DataItem, "Category")%></a><br>
    <asp:Repeater Runat="server"ID="SubCategory" DataSource='<%#((DataRowView)Container.DataItem).Row.GetChildRows("CategoryRelation")%>>

    <ItemTemplate>
        <ahref="category.aspx?category=<%#DataBinder.Eval(Container.DataItem, "["SubCategory"]")%>"><%#((DataRow)Container.DataItem).GetParentRow("CategoryRelation")["Category"] %> - <%# DataBinder.Eval(Container.DataItem,"["SubCategory"]") %></a><br>
    </ItemTemplate>
    </asp:Repeater>
</ItemTemplate>

</asp:Repeater>
... other HTML code ...



This code is both easy to maintain, and performant.
The same principles count for other items bound to databasedata, like the DataGrid for example.

 

Google

All content published on this web site is provided for informational and educational purposes only. Always seek professional advice before making any decisions.

We use third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

This page was updated on Nov 2009 and is Copyright © 2003 by Global Com Consulting Inc.