This is a migrated thread and some comments may be shown as answers.

GridDropDownColumnEditor issue

1 Answer 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael Nagy
Top achievements
Rank 2
Michael Nagy asked on 05 Nov 2008, 10:41 AM
hello ,
i use radGrid in this grid i have  GridDropDownColumn column  .
in edit mode or insert mode i bound the GridDropDownColumn with list and set text and value for item something like that :-

    void Radgrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
            GridEditManager editMan = editedItem.EditManager;

            GridDropDownColumnEditor editor = editMan.GetColumnEditor("OrganizationName") as GridDropDownColumnEditor;
            editor.DataSource = ECMADataManager.GetInstance().Retrieve<Organization>();
            editor.DataTextField = "Name";
            editor.DataValueField = "OrganizationID";
            editor.DataBind();
            if ((e.Item.DataItem as EmpEducation) != null)
                editor.SelectedValue = (e.Item.DataItem as EmpEducation).OrganizationID.ToString();
        }
        else if (e.Item is GridDataItem && !e.Item.IsInEditMode)
        {
            GridDataItem dataItem = (GridDataItem)e.Item;
            Literal litrlContrl = (Literal)dataItem["OrganizationName"].Controls[0];
            litrlContrl.Text = (e.Item.DataItem as EmpEducation).Organization.Name;
        }
    }

i want to add a new item in GridDropDownColumnEditor has text"select one" and has no value . so what can i do ???


1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 06 Nov 2008, 12:48 PM
Hello Michael,

You can use the code below to access RadComboBox in the column and add an item to it:

RadComboBox combo = ((e.Item as GridEditFormItem).EditManager.GetColumnEditor("MyColumn") as GridDropDownListColumnEditor).ComboBoxControl;  
        combo.AppendDataBoundItems = true;  
        combo.Items.Add(new RadComboBoxItem("text","value")); 

Kind regards,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Michael Nagy
Top achievements
Rank 2
Answers by
Nikolay Rusev
Telerik team
Share this question
or