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
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();
Thanks for the reply,As you proposed, I try ClearSelection() function. When I push the button, "wddTablePays.CurrentValue" is empty, "wddTablePays.SelectedValue" is empty too and value of "wddTablePays.SelectedItemIndex" is -1.But on screen, the text area contains "France" after the post back, instead of being empty.
Moreover, I try without set DataSource on every post back and then the dropdownlist container data is empty after the first post back but still functional./***************************************************************/Page_Load code :protected void Page_Load(object sender, EventArgs e){ if (!IsPostBack) { 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); wddTablePays.DataSource = dt; wddTablePays.DataBind(); wddTablePays.CurrentValue = string.Empty; wddTablePays.SelectedValue = string.Empty; } else if (string.IsNullOrWhiteSpace(wddTablePays.CurrentValue)) { wddTablePays.ClearSelection(); }}/***************************************************************/Html code of dropdownlist container after first post back :<div class="igdd_DropDownListContainer " id="x:560418618.5:mkr:DropDown" style="display: block; visibility: visible;" mkr="DropDown"> <div> <table> <tbody><tr> <th> Code </th> <th> Pays </th> </tr> </tbody></table> </div><div style="width: 325px; height: 130px; overflow: auto;" id="x:560418618.6:mkr:DropDownContents" mkr="DropDownContents"> <ul id="x:560418618.7:mkr:List:nw:1" class="igdd_DropDownList " mkr="List" nw="1"><li id="x:560418618.8:adr:0" class="igdd_ListItem " adr="0"> <table> <tbody><tr> <td> </td> <td> </td> </tr> </tbody></table> </li><li id="x:560418618.9:adr:1" class="igdd_ListItem " adr="1"> <table> <tbody><tr> <td> </td> <td> </td> </tr> </tbody></table> </li><li id="x:560418618.10:adr:2" class="igdd_ListItem " adr="2"> <table> <tbody><tr> <td> </td> <td> </td> </tr> </tbody></table> </li></ul> </div></div> /***************************************************************/How to do the text area does not take the first value ?Thanks,
Hello,
It works perfectly.
Thanks for the help.
Thank you for the update.
This is the default behavior to select the first option
You should set it explicitly in the else section
else if (string.IsNullOrWhiteSpace(wddTablePays.CurrentValue))
wddTablePays.CurrentValue = "";
Let me know if you need further assistance.