5 Answers, 1 is accepted

A very simple workaround for this could be just registering to the CellEditorInitializedEvent and do the following:
void
gridView_CellEditorInitialized(
object
sender, GridViewCellEventArgs e)
{
var editor = e.ActiveEditor
as
RadDropDownListEditor;
if
(editor !=
null
)
{
var editorElement = editor.EditorElement
as
RadDropDownListEditorElement;
if
(editorElement !=
null
)
{
editorElement.TextChanged -= editorElement_TextChanged;
editorElement.TextChanged += editorElement_TextChanged;
}
}
}
void
editorElement_TextChanged(
object
sender, EventArgs e)
{
var editorElement = sender
as
RadDropDownListEditorElement;
if
(editorElement !=
null
)
{
if
(
string
.IsNullOrEmpty(editorElement.Text))
{
editorElement.SelectedIndex = 0;
}
}
}
Whenever an item that is not in the list will be selected, the editor.Element.Text will be string.emply so we will just set the first item as selected, thus having an emply selection.
Hope this helps.
Best Regards,
Emanuel Varga MVP
Thank you for your question.
The Text property is not synchronized out of the box with the SelectedIndex property and you should use the solutioin Emanuel proposed.
@Emanuel - thank you for your cooperation.
Regards,
Peter
the Telerik team

Yes the work around works but as far as I am concerned this is a bug that needs to be resolved. Any text entered will be matched and verified against the list but empty text is not. Shouldn't the behaviour be the same as a stand alone control?
Thanks,
Sean
Thank you for sharing your opinion with us.
We will consider including this when planning our future releases, if there is a demand for such a functionality. For the time being, you can continue using the provided workaround which covers this case.
Let me know if you have additional questions.
Regards,
Peter
Telerik

Is this problem still present? I am having the same problem. If the user empties the text the value remains unchanged, if the user chooses the empty value in the dropdown menu, then the value empties.
Alessandro
Hi Alessandro,
This question is a duplicate of one from your support ticket thread. I am sharing the answer also here so that the community can take advantage of it.
When an empty string is present in the drop-down list of the control, clearing the value will not set an item that contains an empty string. The RadDropDownListEditor control string comparison mechanism does not expect to have an empty string. Let me try to explain:
- When an empty string item is NOT present in the drop-down collection: In this case, when the cell commits its value, the internal logic of the control will check if the Text is different from the empty string and perform a search comparison operation to find a match. No match will be found and the SelectedIndex will be set to -1.
- When an empty string item is present in the drop-down collection: The path here is the same as the above one. The difference here is that the string comparison method will find an item that will be the first one in your case. In this scenario, the SelectedIndex won't be set to -1 and the previous valid value will be returned.
This can be workaround by avoiding using empty strings. You can set space or "-" or any other symbol.
new CLuogo { id = 0, codice = "", nome = " " },
OR
new CLuogo { id = 0, codice = "", nome = "-" },
This behavior was discussed with the development team and it was concluded that there is room for improvement. That is why I have logged it in our Feedback Portal where you can track its progress and vote for its implementation. By voting, you are increasing its priority.