Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
990
WebDropDown SelectedItemIndex doesn't reset when clear the search field
posted

Hello,

I am using editable WebDropDown and Infragistics Web version 11.1.
When user select data from List and submit, I can get value from "CurrentValue" and index from "SelectedItemIndex" properties during postback in button OnClick event. 
But if user delete value with "Delete" keybord button and click button, "CurrentValue" and "SelectedItemIndex" properties keep previous value during OnClick event.

Aspx file :
/***************************************************************/
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="TestWebCombo11_1._Default" %>
<%@ Register Assembly="Infragistics35.Web.v11.1, Version=11.1.20111.2064, Culture=neutral, PublicKeyToken=aaaaaaaaaaaaaaaaa"
    Namespace="Infragistics.Web.UI.ListControls" TagPrefix="iglc" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <iglc:WebDropDown ID="wddTablePays" runat="server" SkinID="WebDropDownStandard" EnableTheming="true"
        Width="220px" DropDownOrientation="BottomRight" EnableDropDownAsChild="false"
        DropDownAnimationDuration="1000" DropDownContainerWidth="325px" DropDownContainerHeight="130px"
        EnableCustomValues="false" EnableCaseSensitivity="false" EnableCustomValueSelection="false"
        AutoPostBack="false" ValueField="CodeIso" TextField="Libelle">
        <Items>
        </Items>
        <HeaderTemplate>
            <table>
                <tr>
                    <th>
                        Code
                    </th>
                    <th>
                        Pays
                    </th>
                </tr>
            </table>
        </HeaderTemplate>
        <ItemTemplate>
            <table>
                <tr>
                    <td>
                        <%# DataBinder.Eval(Container.DataItem, "CodeIso")%>
                    </td>
                    <td>
                        <%# DataBinder.Eval(Container.DataItem, "Libelle")%>
                    </td>
                </tr>
            </table>
        </ItemTemplate>
    </iglc:WebDropDown>
    <asp:Button ID="Btn" runat="server" OnClick="Btn_OnClick" />
    <asp:Label ID="lblSelectedValue" runat="server" Text="SelectedValue : " />
    <asp:Label ID="valueSelectedValue" runat="server" Style="background-color: yellow;" />
    <asp:Label ID="lblCurrentValue" runat="server" Text="CurrentValue : " />
    <asp:Label ID="valueCurrentValue" runat="server" Style="background-color: yellow;" />
    <asp:Label ID="lblSelectedIndex" runat="server" Text="SelectedIndex : " />
    <asp:Label ID="valueSelectedIndex" runat="server" Style="background-color: yellow;" />
</asp:Content>
/***************************************************************/

Aspx.cs file :
/***************************************************************/
using System;
using System.Data;

namespace TestWebCombo11_1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("CodeIso");
            dt.Columns.Add("Libelle");

            DataRow dr = dt.NewRow();
            dr[0] = "Fra";
            dr[1] = "France";
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr[0] = "Ita";
            dr[1] = "Italie";
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr[0] = "Esp";
            dr[1] = "Espagne";
            dt.Rows.Add(dr);

            string currentValue = !IsPostBack ? string.Empty : wddTablePays.CurrentValue;
            string selectedValue = !IsPostBack ? string.Empty : wddTablePays.SelectedValue;
            wddTablePays.DataSource = dt;
            wddTablePays.DataBind();
            wddTablePays.CurrentValue = currentValue;
            wddTablePays.SelectedValue = selectedValue;
        }

        protected void Btn_OnClick(object sender, EventArgs e)
        {
            valueCurrentValue.Text = wddTablePays.CurrentValue;
            valueSelectedIndex.Text = wddTablePays.SelectedItemIndex.ToString();
            valueSelectedValue.Text = wddTablePays.SelectedValue;
        }
    }
}
/***************************************************************/

How to clear "CurrentValue" and  "SelectedItemIndex" ?

Thanks

 

Parents
  • 19693
    posted

    Hello ,

    Thank you for posting in our forums.

    I appreciate the isolated sample

    You do not need to set DataSource and CurrentValue on every post back

    Please refer to the modified part of the code and let me know if you need further assistance

       if (!IsPostBack)

            {

                wddTablePays.CurrentValue = string.Empty;

                wddTablePays.SelectedValue = string.Empty;

                wddTablePays.DataSource = dt;

                wddTablePays.DataBind();

            }

     

            if (wddTablePays.CurrentValue == "")

            {

                wddTablePays.ClearSelection();

            }      

Reply Children