Hi. I use a TreeList with autogenerated columns and I create my TreeList control programmatically in Page_init event.
I need to show the "selected" Items stored in DB and for this I write my code in Pre_render event.
I have two critical questions:
1) is there a way to find an item by his PrimaryKey, without looping all items?
2) How to ensure visible my selectedItems? I try this but it fail (ie. my parent node remain close ... in my sample code I suppose to have only 2 level)
In my case I have no paging and I avoid the "Load on demand" scenario.
Some suggestion?
Thanks
Michela
I need to show the "selected" Items stored in DB and for this I write my code in Pre_render event.
I have two critical questions:
1) is there a way to find an item by his PrimaryKey, without looping all items?
2) How to ensure visible my selectedItems? I try this but it fail (ie. my parent node remain close ... in my sample code I suppose to have only 2 level)
void MyCustomTreeList_PreRender(object sender, EventArgs e) {...foreach (var item in this.Items) { string pkey = item.GetDataKeyValue(this.DataKeyNames[0]).ToString(); if (SelectedKey.Contains(pkey)) { item.Selected = true;// How to ensure visible????// if (item.ParentItem != null)// item.ParentItem.Expanded = true; }... }In my case I have no paging and I avoid the "Load on demand" scenario.
Some suggestion?
Thanks
Michela