GridDropDownColumnEditor issue

2 posts, 0 answers
  1. Michael Nagy
    Michael Nagy avatar
    18 posts
    Member since:
    May 2008

    Posted 05 Nov 2008 Link to this post

    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 ???


  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 06 Nov 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top