How do I set the initial value for a dropdown?

2 posts, 0 answers
  1. David
    David avatar
    8 posts
    Member since:
    May 2008

    Posted 16 Aug 2011 Link to this post

    I have a dropdownlist editor as a column. I have loaded it with the values "", "s", "m"

    I have an object that has an "s" stored in it...when I initialize the editor I would like to load the initial value that the object has in it....but I can't get it to work. The value of the cell is always null even after I set it.


    private void rgcSoil_CellEditorInitialized(object sender, GridViewCellEventArgs e)
                if (e.Column.Name != "colSorM")
                RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor;
                if (editor != null)
                    var ee = (RadDropDownListEditorElement)((RadDropDownListEditor)this.rgcSoil.ActiveEditor).EditorElement;
                    ee.DataSource = new String[] {"", "S", "M" };
                    SoilType st = (SoilType)e.Row.Tag;
                    ee.Value = st.StandardOrModified;
  2. Stefan
    Stefan avatar
    2911 posts

    Posted 19 Aug 2011 Link to this post

    Hello David,

    Thank you for writing.

    I am not sure I fully understand your scenario. If you want to have different data sources for each row of GridViewComboBoxColumn, please refer to the following KB article. Otherwise, if the binding is OK and you just want to set the value of the active editor, you can do that with the following code in the CellEditorInitialized event handler:
    e.ActiveEditor.Value= st.StandardOrModified;

    I hope that you find this information helpful. Should you have any other questions, do not hesitate to contact us.
    Kind regards,
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Back to Top