C# – Devexpress controls clear selection

asp.netcdevexpress

I have the DevExpress controls within update panel and I need to clear selection on all of them from server side. Like DdlDropDownList.ClearSelection(); but in DevExpress simple actions are handled differently.

ASPxComboBox
ASPxDateEdit
ASPxTextBox

Does anyone know the best implementation of required functionality.

Best Answer

Try setting the Value property of those controls to null.

DdlDropDownList.Value = null;

Here's the documentation for those 3 controls:

http://documentation.devexpress.com/#AspNet/clsDevExpressWebASPxEditorsASPxComboBoxtopic
http://documentation.devexpress.com/#AspNet/clsDevExpressWebASPxEditorsASPxDateEdittopic
http://documentation.devexpress.com/#AspNet/clsDevExpressWebASPxEditorsASPxTextBoxtopic

Here's a sample that worked for me with version 9.2. The "Clears" button clears the editor while the "Doesn't Clear" button doesn't.

<dxe:ASPxComboBox ID="a" runat="server" ValueType="System.String">
    <Items>
        <dxe:ListEditItem Text="1" Value="1" />
        <dxe:ListEditItem Text="2" Value="2" />
        <dxe:ListEditItem Text="3" Value="3" />
    </Items>
</dxe:ASPxComboBox>
<dxe:ASPxDateEdit ID="b" runat="server" />
<dxe:ASPxTextBox ID="c" runat="server" Width="170px" />
<asp:Button runat="server" Text="Clears" OnClick="Button1_Click" />
<asp:Button runat="server" Text="Doesn't Clear" />

protected void Button1_Click(object sender, EventArgs e)
{
    a.Value = null;
    b.Value = null;
    c.Value = null;
}
Related Topic