|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to add DataSource to a TreeView programmaticallyim creating a custom control (custom SPField in WSS v3) that renders a TreeView control. This works fine if i add TreeNodes manually to the nodes collection, but what i really want to do is add a SiteMap provider as datasource for the control. I am doing this programmatically in CreateChildControls but so far without much luck: I get no errors, but the TreeView renders without any data in it. Code (inside CreateChildControls of component): _siteMapDataSource = new SiteMapDataSource(); //defined outside method _siteMapDataSource.SiteMapProvider = "SPContentMapProvider";//taken from web.config _siteMapDataSource.StartFromCurrentNode = true; _siteMapDataSource.ShowStartingNode = false; _siteMapDataSource.DataBind();//not sure this is necesarry.. _spTreeView.DataSourceID = _siteMapDataSource.ID; _spTreeView.DataBind(); I tried with all the sitemap providers in web.config but none of them seems to work... any help or hint appreciated! :-) thx //AndersR This appears to be all that is required.
SiteMapDataSource smds = new SiteMapDataSource(); smds.Provider = SiteMap.Providers["Default"]; // Name from web.config TreeView1.DataSource = smds; TreeView1.DataBind(); ID is only used when you are using a datasource control.
how to render a graphic and other objects in the same page?
Repeater and Checkboxs Charat Control (date Vs date) Dynamicly setting readonly in through a property Custom UpdatePanel - ASP.NET 2.0 and Client Callback Making a GridView Cell read-only Required Field Validator Help Me Click event for GridView? Click event for GridView |
|||||||||||||||||||||||