dropdown SelectedValue

  •  07-24-2006, 7:38 AM

    dropdown SelectedValue

    Hi,
    I am populating a dropdown in the Editor toolbar using the red code below:
     
    The dropdownlist is populating ok, but I want to be able to display the SelectedValue based on a value obtained from the database. So instead of always displaying the caption "Template" I want to display the name of the template that is brought out of the database - based on its ID.
    As a test, I have tried  ddlTemplates.SelectedItem.Value = 311 (311 is a TemplateID in the database)
    This has the effect of appending the value of 311 to the caption  - resulting in:
    <option value="311" selected="True">Template</option> the value of 311 has been appended to this item. Previously the value was "".
     
    I actually want black_template selected because it has the value of 311 taken from the database.
    <option value="311"> black_template</option>
     
    There does not seem to be the option to get the SelectedValue of a RichDropDownList
     
    Do you have any suggestions?
    Thank you.
     
     
     
    Dim container As System.Web.UI.Control
        container = Editor1.ToolControls("custom").Control
        Dim ddlTemplates As CuteEditor.RichDropDownList
        ddlTemplates = New CuteEditor.RichDropDownList(Editor1)
     
        'must set this css name
        ddlTemplates.CssClass = "~/styles/AcmsMain.css"
        'add the first item (caption)
        ddlTemplates.Items.Add("[[Template]]", "")
     
        'hide the first item (caption) in the float-panel
        ddlTemplates.RichHideFirstItem = True
       
        container.Controls.Add(ddlTemplates)
      
        Dim objRdr As SqlClient.SqlDataReader = Nothing
        objRdr = SiteDB.SiteGetTemplatesByPage(PageID, NewPage)
        If Not Page.IsPostBack Then
          Try
            While objRdr.Read
              ddlTemplates.Items.Add(objRdr("Name"), objRdr("TemplateID"))
              
            End While
          Finally
            objRdr.Close()
          End Try
        End If
     
     
View Complete Thread