dropdownlist in toolbar populated from a database

  •  06-26-2006, 8:06 AM

    dropdownlist in toolbar populated from a database

    Hi,

    I would like to add a normal dropdownlist to the Cute Editor toolbar.
     
    The dropdownlist needs to be populated from a database.
     
    On saving the contents of the editor, the selected value of the dropdownlist also needs to be saved to a database.
     
    Do you have an example of this along with example code please?
     
    I have looked at the code for adding a custom button. This did not help me.
     
    I am using  asp.net 2.0 with VB.
     
     
    Below is the code I am currently using in code behind:
     
     
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

     
    PopulateTemplateDropDown()
     
    End Sub
     

    Protected Sub PopulateTemplateDropDown()

    Dim PageID, NewPage As Integer

    PageID = Session(SessTypes.TreeViewID)

    If (Request.QueryString("Edit")) = Nothing Then

    NewPage = 1

    Else

    NewPage = 0

    End If

    Dim objRdr As SqlClient.SqlDataReader = Nothing

    objRdr = SiteDB.SiteGetTemplatesByPage(PageID, NewPage)

    Dim ddlTemplates

    ddlTemplates = Editor1.FindControl("ddlTemplates")

    Try

    If Not ddlTemplates Is Nothing Then

    ddlTemplates.DataTextField = "Name"

    ddlTemplates.DataValueField = "TemplateID"

    ddlTemplates.DataSource = objRdr

    ddlTemplates.DataBind()

    ddlTemplates.Items.Insert(0, New ListItem("Select", ""))

    End If

    Finally

    objRdr.Close()

    End Try

    End Sub
     
     
     
     
    In config file:

    <item type="dropdown" id="ddlTemplates" name="ddlTemplates" text="[[Template]]" postback="True" RenderItemBorder="true" commandname="SaveTemplate" commandargument="SaveTemplate" />

     
    The above does not generate an error, but does not populate the dropdownlist with values from the database.
     
    Thank you in advance.
View Complete Thread