We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Treeview Template Itemdatabound?

Thread ID:

Created:

Updated:

Platform:

Replies:

69650 Nov 6,2007 12:13 PM Nov 10,2007 07:07 AM ASP.NET Web Forms (Classic) 2
loading
Tags: Tools
Kathy Gray
Asked On November 6, 2007 12:13 PM

I am working on a treeview with a template that has a dropdownlist in it. Since I cannot databind on the Listitem in order to set the selected item, I am wondering how I can do this? In gridview, I would use the RowDataBound event. Is there anything similar to this for the treeview?

Here is my Treeview Template:





Kathy Gray
Replied On November 6, 2007 05:06 PM

I am also wondering if there is a way to access this dropdownlist in the server code, if I have the treeviewnode associated with it. In other words, how do I ask the code for the dropdownlist that is in the template for a specific node?

>I am working on a treeview with a template that has a dropdownlist in it. Since I cannot databind on the Listitem in order to set the selected item, I am wondering how I can do this? In gridview, I would use the RowDataBound event. Is there anything similar to this for the treeview?

Here is my Treeview Template:







Melba Winshia [Syncfusion]
Replied On November 10, 2007 07:07 AM

Hi Kathy,

Thank you for your interest in Syncfusion Products.

1) Since I cannot databind on the Listitem in order to set the selected item, I am wondering how I can do this?

If your intention is to set the selected item with dynamic data binding on the asp.net page, then it can be achieved by following the techniques discussed in the below forum:

http://forums.asp.net/p/1156810/1901549.aspx

If I have misunderstood your requirement, could you please explain me in detail, so that I can work in depth and try to send a better solution?

2) if there is a way to access this dropdownlist in the server code

Yes. You can access the dropdownlist in the server code. But for this you must add the control in the TemplateControl collection on the server side.

[C#]


//Create new instance of TreeView Template Control
TreeViewTemplateControl CalendarControl = new TreeViewTemplateControl();
CalendarControl.ID = "calendarControl"

//Add Calendar control in the TemplateControl collection
CalendarControl.Controls.Add(Calendar1);

//Add TemplateControl in the Templates collection
TreeView1.Templates.Add(CalendarControl);

//Assign Template ID to TreeView Node
Calendar.TemplateID = "calendarControl";

//Access the dropdownlist
this.Calendar1.BackColor = System.Drawing.Color.Lavender;


Please refer the sample in the below link which illustrates the above:

http://www.syncfusion.com/Support/user/uploads/TreeViewWithTemplat_28ea0b58.zip

Please try this and let me know if this helps.

Thanks,
Melba






CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;