Welcome Guest Search | Active Topics | Sign In | Register

Using CustomItem recursively Options
Scott_Pulliam
Posted: Monday, January 14, 2013 4:05:57 PM
Rank: Newbie
Groups: Member

Joined: 1/8/2013
Posts: 4
I would like to use the CustomItem at every level of a treeview bound to a xml datasource. I've successfully created the xml and bound with XPath. As I do not know in advance the number of levels I think I will ultimately need to "nest" templates recursively. Can I do this?

Without recursion the treeview code I have resort to:

<TemplateItem >
----- <CustomItem>
---------- <asp controls>
---------- <asp controls>
---------- <asp controls>
----- <SubGroup>
---------- <TemplateItem >
-------------- <CustomItem>
------------------- <asp controls>
------------------- <asp controls>
------------------- <asp controls>
-------------- <SubGroup>
------------------- <TemplateItem >
------------------------ <CustomItem>
---------------------------- <asp controls>
---------------------------- <asp controls>
---------------------------- <asp controls>
... on and on...

I do not see an obvious way to do this from extensive reading of your samples.

TIA


eo_support
Posted: Monday, January 14, 2013 4:15:42 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

Theoretically you can do that with code, but there is no way for you to do it declaratively in ASPX. If you do it with code, you would just have to dynamically create CustomItem object and then set the target item's CustomItemID to the ID of the newly created CustomItem object. If you only intend to display contents with CustomItem, then that's all needed. However if you also intend to handle events and keep status information across posts back CustomItem, then it can get very tricky --- you must recreate all CustomItem in exactly the same order as they were initially created during the post back. Otherwise event won't fire properly. This behavior is not particular related to the CustomItem, but it's one that is required by ASP.NET whenever you dynamically create controls with code.

Over all, if it is something you can do with simple HTML, then we would recommend you to use MenuItem.Text.Html instead. CustomItem is very useful for a single item, or if you know how many levels you have. However maintaining status information across post back for dynamically created controls can quickly become a nightmare. So we would recommend against that.

Thanks!
Scott_Pulliam
Posted: Monday, January 14, 2013 4:35:30 PM
Rank: Newbie
Groups: Member

Joined: 1/8/2013
Posts: 4
Wow! That was fast.

Not the answer I wanted to hear but it is what it is. Yes, I need to be able to display and handle events ideally to trigger server side functions.

Ok, I will shift to trying to do this dynamically. Thank you.
eo_support
Posted: Monday, January 14, 2013 4:47:01 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
You are welcome. Let us know if there is anything else.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.