How to add dynamically from code behind a Link list in dropDownList

Last post 11-26-2013, 4:53 PM by Raney. 4 replies.
Sort Posts: Previous Next
  •  11-25-2013, 5:53 PM 78430

    How to add dynamically from code behind a Link list in dropDownList

    Hi,

    I would like add dynamically from code behind a link list (text with url) in a DropDownList.

    So when a text is marked then the selected link from the dropDownList will be placed as <a href>

    Thanks for help and an example in VB.NET or C#

    Raney 
  •  11-26-2013, 6:38 AM 78434 in reply to 78430

    Re: How to add dynamically from code behind a Link list in dropDownList

    Hi Raney,

     

    Please try the way below to add the links dynamically. More details please refer to http://cutesoft.net/developer+guide/scr/Links_dropdown_Customization.htm 

     

    C# Example:

    1. if (!IsPostBack) {    
    2.    CuteEditor.ToolControl toolctrl=Editor1.ToolControls["LinkTree"];    
    3.    if(toolctrl!=null) {    
    4.       CuteEditor.TreeDropDownList tdd=(CuteEditor.TreeDropDownList)toolctrl.Control;    
    5.       //clear the items from configuration files    
    6.       tdd.Items.Clear();    
    7.       CuteEditor.TreeListItem rootitem=new CuteEditor.TreeListItem("Root",null);   
    8.       rootitem.Selectable=false;    
    9.       tdd.Items.Add(rootitem);    
    10.       rootitem.Items.Add("Asp.Net","Asp.Net","http://asp.net");    
    11.       rootitem.Items.Add("DotNetNuke.Net","DotNetNuke.Net","http://DotNetNuke.com");    
    12.       rootitem.Items.Add("CuteSoft","CuteSoft","http://CuteSoft.net");          
    13.    }    
    14. }  

    VB Example:


    1. If Not Page.IsPostBack Then  
    2.   If Not Editor1.ToolControls("LinkTree"Is Nothing Then  
    3.       Dim tdd As CuteEditor.TreeDropDownList   
    4.       Dim richitem As CuteEditor.RichListItem   
    5.       tdd = DirectCast(Editor1.ToolControls("LinkTree").Control, CuteEditor.TreeDropDownList)   
    6.       'clear the items from configuration files    
    7.       'see Configuration/Shared/Common.config    
    8.       tdd.Items.Clear()    
    9.       'Add items by code    
    10.       Dim rootitem As CuteEditor.TreeListItem    
    11.       rootitem=new CuteEditor.TreeListItem("Root")    
    12.       rootitem.Selectable=false    
    13.       tdd.Items.Add(rootitem)    
    14.       rootitem.Items.Add("Asp.Net","Asp.Net","http:'asp.net")    
    15.       rootitem.Items.Add("DotNetNuke.Net","DotNetNuke.Net","http:'DotNetNuke.com")    
    16.       rootitem.Items.Add("CuteSoft","CuteSoft","http:'CuteSoft.net")   
    17.   End If  
    18. End If  

     

    Regards,

     

    Ken 

  •  11-26-2013, 3:44 PM 78438 in reply to 78434

    Re: How to add dynamically from code behind a Link list in dropDownList

    Thanks Ken,

    Do you have an example how to config CuteEditor or what do setup up to see the CuteEditor.TreeDropDownList in the Editor?

    Thanks a lot!
  •  11-26-2013, 4:07 PM 78440 in reply to 78438

    Re: How to add dynamically from code behind a Link list in dropDownList

    Hi Raney,

     

    The code I sent already shows you how to use the TreeDropDownList,  What do you mean set up to see it? 

     

    Regards,

     

    Ken 

  •  11-26-2013, 4:53 PM 78441 in reply to 78440

    Re: How to add dynamically from code behind a Link list in dropDownList

    Ken, thanks code works fine!
View as RSS news feed in XML