I'm making an asp.page that will display hierarchical information about company assets.
To grab the data I used a lambda expression:
FASAssetInfoDataContext fasInfo = new FASAssetInfoDataContext();
var data = from g in fasInfo.Asset_Informations
where g.Department.Substring(0, 3) == p
select g;
Dictionary<string, Dictionary<string, List<info>>> branch = data.GroupBy(e => e.Location)
.ToDictionary(g => g.Key,
g => g.GroupBy(gl => gl.G_L_Asset_Acct_No)
.ToDictionary(gl => gl.Key,
gl => gl.Select(s => new info
{
acqDate = s.Acquisition_Date,
asstNo = s.Co_Asset_Number,
classInfo = s.Class,
description = s.Description,
mfgSerialNo = s.Mfg_Serial_No,
deprThisRun = s.Depr_This_Run__Int_,
AcqValue = s.Acquisition_Value__Int_,
currentAccDepr = s.Current_Accum_Depr__Int_,
estLife = s.Est_Life__YYMM___Int_,
inServiceDate = s.Placed_In_Service_Date__Int_,
netBookValue = s.Current_Net_Book_Value__Int_,
oldAcqValue = s.Acquisition_Value__Tax_
}).ToList()));
So I now have a nested set of dictionaries with a list of information at the end. My question is how do I best display this information on the page itself? I can get the first level but have been struggling to get the nested repeater to function properly. If there is a better control to use I'm all ears :)
Thanks,
Marco
If you do indeed need to use nested repeaters, its possible, but getting it working isn't particularly obvious. The following would work (simplified for brevity):
Code behind:
asp:TreeView? Not sure how it will handle the nested data set but it's designed to display it.
There's an nicer way of doing this without any ItemDataBound events. For simplicity let's assume two level of repeaters.
I usually prefer this way, since for some reason I hate ItemDataBound events :)