This project is read-only.

set DetailCollectionID

Topics: User Forum
Feb 9, 2009 at 6:43 PM
How do I set the DetailCollectionID?  Can I do it when I do the SetDetail?  I did the usual thing:
    [EditableTextBox("LocationHours", 3)]
    public virtual string LocationHours
        get {  return (string)(GetDetail("LocationHours") ?? string.Empty);  }
        set {  SetDetail("LocationHours", value, string.Empty);  }
Worked great on the target page, until later, when I tried this _on_another_drill-down_page_:
DetailCollection dc = GetDetailCollection("LocationHours", false);
DetailCollection (dc) was empty.  Checked the database:
select [ID], [Type], [ItemID], [DetailCollectionID], [Name], [StringValue] from dbo.n2Detail (nolock) where Name = 'LocationHours'

10 rows returned.  Looks good, except DetailCollectionID always = null.

The long story:
I have a collection of 10 stores on a page.  Editable store data contains the usual (phone, address, hours of operation, etc).  On drill down, into a specific store, I need to display the data again.  It sounds like GetDetailCollection(...) will get me what I need, once I learn how to populate it.  Yes, it might be better logic to edit the data in the drill-down-detail page and re-call-it in the parent summary page.  Either way, to make it happen, I think I need GetDetailCollection(...).

Thank you.
- Matt

Feb 9, 2009 at 7:51 PM
Take a look at the database model.

The link between n2detailcollection and n2detail is optional. It's used when adding multiple values to a detail collection retrieved through ContentItem.GetDetailCollection("CollectionName", true).

For values stored through SetDetail the detail collection is null by design.
Feb 24, 2009 at 8:29 AM
Libardo, I am trying to understand the database model but I don't quite understand the need for n2DetailCollection. What is the difference between adding a certain amount of details to a details collection and then linking them to an n2Item and linking a bunch of n2Details directly to an n2item.
For example speaking of a user. I add a new user and specify its roles. Now in the database this user item has 4 details all named "roles". Each of these details however is grouped again in a detailcollection. Why is there a need for that table?
As far as I can see you could just retrieve a certain user's roles directly without the need for that table?

Feb 24, 2009 at 12:11 PM
with a little (non-breaking!) patch you can use a DetailCollections as a Dictionary of Dictionaries of Details.. this is usefull, for example, to store a catalog entity with a dynamically typed properties, grouped by categories
Feb 24, 2009 at 7:31 PM
The initial reason for the detal collection was to store a number tags, and to add a parent trail collection. Basically the detail collection comes into play when there is a need to group multiple values. The details by themselves only stores a single value which is accessed with dictionary semantics.