If I have a datatable which looks like this:
Record Id, Group Id, Name
1, 1, Test 1
2, 1, Test 2
3, 2, Test 3
4, 3, Test 4
Is it possible to use nested repeaters to group the information by GroupId?
e.g. displaying something like
Group 1
Test 1
Test 2
Group 2
Test 3
Group 3
Test 4
I normally do this with two datatables inside a dataset and link the group
id column, but in this case I only have a flat datatable like the above.
TIA
--
Leon Mayne http://leon.mvps.org/ 3 9457
You can, if you wish, try nested repeaters, but you can easily get away with
just one repeater.
Make an itemtemplate as 2 table rows. Put group id in the top row and record
name and id in the second. Make your data source return records sorted by
group id. Databind the repeater. In the PreRender event loop through the
repeater items and hide all group rows except the first for every group id.
That's it.
A big advantage of this way over nested repeaters is that all record rows
will be aligned nicely since they are all in the same table.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Leon Mayne" <le**@rmvme.mvp s.orgwrote in message
news:BC******** *************** ***********@mic rosoft.com...
If I have a datatable which looks like this:
Record Id, Group Id, Name
1, 1, Test 1
2, 1, Test 2
3, 2, Test 3
4, 3, Test 4
Is it possible to use nested repeaters to group the information by
GroupId? e.g. displaying something like
Group 1
Test 1
Test 2
Group 2
Test 3
Group 3
Test 4
I normally do this with two datatables inside a dataset and link the group
id column, but in this case I only have a flat datatable like the above.
TIA
--
Leon Mayne http://leon.mvps.org/
XML File
<?xml version="1.0" encoding="utf-8" ?>
<Groups>
<category GroupId="1">
<Name>Test 1</Name>
<Name>Test 2</Name>
</category>
<category GroupId="2">
<Name>Test 3</Name>
</category>
<category GroupId="3">
<Name>Test 4</Name>
</category>
</Groups>
=============== =============== =============== =======
Now I am going to take repeater control on the form-- -----
<asp:Repeater id="CategoryRep eater" runat="server" OnItemDataBound ="CategoryRepea ter_ItemDataBou nd">
<HeaderTemplate >
<h2>Group Information</h2>
<ul>
</HeaderTemplate>
<FooterTemplate >
</ul>
</FooterTemplate>
<ItemTemplate >
<li><b><%# Eval("GroupID") %></b></li>
<%-- adding one more repeater within this item template --%>
<asp:Repeater id="PlayerRepea ter" runat="server">
<HeaderTemplate >
<ul>
</HeaderTemplate>
<FooterTemplate >
</ul>
</FooterTemplate>
<ItemTemplate >
<li><%# Eval("Name_Text ") %></li>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
=============== =============== =============== ====
next proceed to Code Behind File ----------
using System;
using System.Data;
using System.Configur ation;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Web.UI.H tmlControls;
public partial class _Default : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
if (!IsPostBack)
{
DataSet ds = new DataSet();
ds.ReadXml(MapP ath("./Group.xml"));
CategoryRepeate r.DataSource = ds;
CategoryRepeate r.DataBind();
}
}
protected void CategoryRepeate r_ItemDataBound (object sender, RepeaterItemEve ntArgs e)
{
RepeaterItem item = e.Item;
if (item.ItemType == ListItemType.It em || item.ItemType == ListItemType.Al ternatingItem)
{
Repeater PlayerRepeater = (Repeater)item. FindControl("Pl ayerRepeater");
DataRowView drv = (DataRowView)it em.DataItem;
PlayerRepeater. DataSource = drv.CreateChild View("category_ Name");
// here u can also bind the Child Repeater with DataTable like
//PlayerRepeater. DataSource = datatableName;
PlayerRepeater. DataBind();
}
}
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: DonRex |
last post by:
Hello all!
I couldn't find a web application-newsgroup for ASP.NET, so I'm sorry if
this is the wrong forum!
Synopsis:
In my webform I have 3 nested repeaters:
rpWeeks
----- rpTime
|
by: Ed Allan |
last post by:
I have extended the example at
http://support.microsoft.com/default.aspx?scid=kb;EN-
US;306154 to build a webform page with 3 layers of nested
Repeaters (ie. parent, child and grandchild).
I added a third DataTable to the DataSet, and created a
second Relation between the second and third DataTables.
On the aspx page I copied the child...
|
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 get the code in a text file.
>
>Thanks - Ed
>
|
by: Paul |
last post by:
I want to be able to nest a repeater in a datagrid or datalist. I'm not
unduly bothered about a master/child relationship as such as there'll at
this stage only ever be one record on the page, but that record can be
allocated to a number of categories (in fact two sets of categories, so
I think i'll need two repeaters. )
Imagine a...
|
by: Machi |
last post by:
let say in parent-child scenerio (Product: Product Category - one product category may has many products), i am using nested repeaters where parent repeater will be used to display info and child repeater will be used to display info, i define the parent and child repeaters once in HTML tag, and create the repeaters for different categories and...
| |
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). But... and this is the crappy
part, the nested repeater's events are fired twice. How do I know this? I
setup global private counter variables...
|
by: Josh |
last post by:
I have a nested repeater situation with a Link Button on the nested
repeater. However when the link button is clicked I get a postback but the
event never takes place.
I'm trying to wire up the nested repeaters ItemCommand event in the
ItemDataBound of the outer repeater. I have even tried sharing the Outer
repeaters ItemCommand event but...
|
by: PrinsonG |
last post by:
My Query is How do I export to excel/csv using Nested Repeaters.
My project is web-based and i am using C#.Net. In this i use three repeaters.
one displays ID, Name of the user.
second displays break details.
third displays total time spent.
|
by: andrew.douglas11 |
last post by:
Hello all,
Is it possible to share controls inside a child repeater? Here's the
situation: I have a web page that needs to display data grouped by A,
and alternatively by B (only one grouping displayed at a time through
Panel.Visible). A and B both share common child data: C. I have 2
parent repeaters corresponding to A and B, and each...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |