Skip to content

How to use ValueChanged Event?

New Discussion
mike
mike asked on May 7, 2009 7:22 PM

Hi,

I binding the webdropdown with sqldatasource, but when i choosed the dropdown item,can not cause

the ValueChanged event to fire.

Those are my codes.

CLIENT:

<ig:WebDropDown ID=”dpEmp” runat=”server” Width=”200px”
EnableAutoFiltering=”Client” DropDownContainerHeight=”300px”
DataSourceID=”SqlDataSource1″  TextField=”CN”
AutoFilterQueryType=”Contains” AutoFilterResultSize=”100″
AutoFilterTimeoutMs=”2000″ AutoPostBack=”True”
onvaluechanged=”dpEmp_ValueChanged” DataKeyFields=”Code”
ValueField=”Code”
>
<DropDownItemBinding TextField=”CN” ValueField=”Code”></DropDownItemBinding>
<AutoPostBackFlags SelectionChanged=”On” ValueChanged=”On” />
</ig:WebDropDown>

<asp:SqlDataSource ID=”SqlDataSource1″ runat=”server”
ConnectionString=”<%$ ConnectionStrings:ExpenseLineConnectionString %>”

SelectCommand=”SELECT Code+Name AS CN, Code FROM TCCEmp WHERE (CCEmp = @CCEmp)”>
<SelectParameters>
<asp:Parameter DefaultValue=”E” Name=”CCEmp” Type=”String” />
</SelectParameters>
</asp:SqlDataSource>

SERVER:

protected void dpEmp_ValueChanged(object sender, Infragistics.Web.UI.ListControls.DropDownValueChangedEventArgs e)
{

}

Sign In to post a reply

Replies

  • 0
    Alexander Todorov
    Alexander Todorov answered on May 7, 2009 9:36 AM

    Hi,

    Since you have AutoPostBack flags for both SelectionChanged and ValueChanged defined, value changed will never be invoked, because selection happens first, and causes a postback immediately, only after that the value change code is executed on the client, but because of the postback, it doesn't get actually executed in your case.

    I suggest removing autoPostBackFlag for SelectionChanged (or setting it to Off, which is the default value). This way you will still get the selection changed events fire on the server, but only the postback will be triggered by the value change event from the client.

    Hope this helps,

    Angel 

    • 0
      mike
      mike answered on May 7, 2009 10:22 AM

      Hi Angel,

      I had taken your advice and set SelectionChanged to Off(<AutoPostBackFlags ValueChanged="On" />),

      but still don't work. Oh…How can i do now?

      • 0
        Alexander Todorov
        Alexander Todorov answered on May 7, 2009 10:52 AM

        Hi,

        In your sample you also have AutoPostBack="True". This will make all autopostback flags set to On, including the SelectionChanged. You should set this to False, or not set it at all.

        Hope this helps,

        Angel 

  • 0
    Robert
    Robert answered on May 7, 2009 6:26 PM

    I'm seeing exactly the same behavior. To simplify things and get away from any complications caused by my SQL data source, I created a page with nothing on it other than a simple WedDropDown with a hard coded list of items. No matter what combination of "autopostback" properties I select, neither the SelectionChanged nor ValueChanged events in the VB code behind file fire. Additionally, since I also set a breakpoint in the Page_Load event, I can see that no postback at all is taking place, let alone having those events triggered.

    • 0
      Robert
      Robert answered on May 7, 2009 7:03 PM

      I found another post where Angel suggests adding a <ClientEvents /> declaration and that at least got the events to fire.

      <ig:WebDropDown ID="cboSimple" … MultipleSelectionType="Checkbox" PageSize="0">
              <ClientEvents />
              <AutoPostBackFlags SelectionChanged="On" />
              <Items>

      But there still two "minor" issues. (1) Regardless of the combination of SelectionChanged = On/Off and ValueChanged = On/Off, if either is set, both events fire if they have code. (2) The response to the users click on an item in the drop down list is very slow. It takes about 3 seconds to see a response on my system, and that's without the code doing anything other than assigning a string variable.

      • 0
        Alexander Todorov
        Alexander Todorov answered on May 7, 2009 7:22 PM

        Hi,

        Thanks for bringing this up. The presence of the  <ClientSideEvents /> so that the events fire is a known issue and has already been fixed. Should be out in the next Service Release for this month.

        This is the correct behavior – both will fire, because when you select an item, the value is also automatically updated. If you don't want ValueChanged to fire, add a handler for the ValueChanging client-side event, and cancel it : 

        args.set_cancel(true);

        If your AutoPostBackFlag is set to Async, it's normal for selection to be slow, because depending on round-trip time, from the time you select, until the response is back, it does an async postback. 3 seconds is too much, i would investigate what is being invoked on the server-side, maybe DataBinding is called and takes a lot of time. In that case you can use either the Paging or LoadOnDemand features, which will limit the initial number of items rendered and data-bound. (now i see in your example you are not using any sort of databinding to an sql data source or similar) in that case you can investigate using FireBug for example, how long it takes for the response to arrive in terms of network latency. Do you run this locally? If you are using Firefox, you may also try changing "localhost" to "127.0.0.1", it causes well-known DNS issues when combined with the development server, instead of IIS.

        Hope this helps,

        Angel 

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
mike
Favorites
0
Replies
7
Created On
May 07, 2009
Last Post
16 years, 11 months ago

Suggested Discussions

Created by

Created on

May 7, 2009 7:22 PM

Last activity on

Feb 26, 2026 7:14 PM