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

Clear contents of GridDropDownColumn with EntityDataSource?

1 Answer 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 05 Dec 2012, 08:30 AM
How do I clear the contents of a GridDropDownColumn (RadComboBox) which is bound to a EntityDataSource? 

The following code changes the data source of a cascading drop-down, but doesn't clear the contents of the RadComboBox - possibly because it's bound to the the EntityDataSource... (I hope to avoid doing a UNION NULL on the EntityDataSource).

protected void rgUnits_ItemCreated(object sender, GridItemEventArgs e)
       {
           GridEditableItem item = e.Item as GridEditableItem;
            
           if (item != null &&
               item.IsInEditMode &&
               item.OwnerTableView.DataSourceID != DataSourceIDUnitItem) // Parent Row
           {
               RadComboBox combo = (RadComboBox)item["EquipmentType"].Controls[0];
               combo.AllowCustomText = true;
               combo.AutoPostBack = true;
               combo.SelectedIndexChanged += combo_SelectedIndexChanged;
           }
       }
 
       void combo_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
       {
           GridEditableItem editedItem = (sender as RadComboBox).NamingContainer as GridEditableItem;
 
           int equipmentTypeID = 0;
           if (int.TryParse(((RadComboBox)editedItem["EquipmentType"].Controls[0]).SelectedValue, out equipmentTypeID))
           {
               EquipmentDescriptionDataSource.Where = string.Format(EquipmentDescriptionFilter, equipmentTypeID);
 
               RadComboBox rcbEquipmentDescription = ((RadComboBox)editedItem["EquipmentDescription"].Controls[0]);               
               rcbEquipmentDescription.DataBind();
               rcbEquipmentDescription.ClearSelection();
               rcbEquipmentDescription.Text = string.Empty;
           }
       }


Any thoughts?

1 Answer, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 06 Dec 2012, 07:42 AM
I worked it out, the key settings on the GridDropDownColumn are:

EnableEmptyListItem="true" ConvertEmptyStringToNull="true"
Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Share this question
or