Declined
Last Updated: 17 Nov 2015 07:52 by ADMIN
Svetlin
Created on: 26 Feb 2013 09:17
Category: GridView
Type: Bug Report
0
FIX. RadGridView - the display member for empty string value in GridViewComboBoxColumn is not displayed.
The display member for empty string value in GridViewComboBoxColumn is not displayed. The following code reproduces the issue:

GridViewComboBoxColumn cboInsRslCd = new GridViewComboBoxColumn();
cboInsRslCd.DataType = typeof(string);
List<ItemComboBox> liste = new List<ItemComboBox>();
liste.Add(new ItemComboBox("", "[None]"));
liste.Add(new ItemComboBox("A", "A"));
liste.Add(new ItemComboBox("B", "B"));
liste.Add(new ItemComboBox("C", "C"));

cboInsRslCd.DataSource = liste;
cboInsRslCd.ValueMember = "CleItem";
cboInsRslCd.DisplayMember = "ValeurItem";
cboInsRslCd.NullValue = "[None]";
this.radGridView1.Columns.Add(cboInsRslCd);

WORKAROUND:  subscribe to the CellEndEdit event and change the stored value in the event handler:
private void RadGridView1_CellEndEdit(object sender, GridViewCellEventArgs e)
{
    if (e.Value == null)
    {
        e.Row.Cells[e.Column.Name].Value = "";
    }
}

http://www.telerik.com/community/forums/radgridview-comboboxcolumn-displays-no-value-for-member-with-empty-string-value-is-selected
1 comment
ADMIN
Ivan Petrov
Posted on: 11 Nov 2015 15:43
When editing a cell in RadGridView, the grid always converts an empty string to null. In the above case after closing the editor, RadGridView converts the value to null and stores it in its backing failed. When the cell tries to display its content it tries to match its value (null) to one of the values available in the drop down list data source. It doesn't find such a match and becomes empty.
It is a good programming practice is to store NULL in the database instead of an empty string and this is the reason for this behavior of the grid. If you absolutely have to store an empty string in your backing field you can subscribe to the CellEndEdit and change the value in this backing field. This is demonstrated in the workaround provided above.