Hi, I am using the WebDropDown control and binding to datasource at runtime as below.igSearchCombo.TextField = "name";igSearchCombo.ValueField = "id";igSearchCombo.DataKeyFields = "id";igSearchCombo.DataSource = table;igSearchCombo.DataBind();
I have declared a ClientEvent SelectionChanged (for test purpose) and also ServerSide OnSelectionChangd method.
In ClientSide, I can see my selectedItem key showing correctly using eventArgs.getNewSelection()[0].get_value().
My WDD control declaration for TextField, ValueField, DataKeyFields in ASPX page is also set correctly to the right data-column names.
But on serverside, the DropDownSelectionChangedEventArgs e does not show the selectedItem key when I query the e.NewSelection. The later only returns the index of the selected value but not the actual key.
Am I missing something?
Hello Sanatan,Please let me know if you have any further questions regarding this issue.
Hello a105019,
I'm updating this thread based on our chat session we had today. You mentioned you were looking to obtain the Value and Text fields of the selected item.
In the SelectionChanged server event, the argument "sender" is the WebDropDown. From this, you can access the items and the values you are looking for by using the following code:
WebDropDown wdd = (WebDropDown)sender;wdd.Items[(int)e.NewSelection].Text;wdd.Items[(int)e.NewSelection].Value;
If you have any further questions, please let us know.
Hi, I just tried the code with a minor change (see in bold) and it it not working either.for (int i = 100; i <= 120; i++) { row = table.NewRow(); row["id"] = i; .... } return table;
The e.NewSelection seem to return the itemIndex instead of the DataKey of selected item. Not sure if it is a version issue ... I am using Version=10.3.20103.2120 controls.
Thanks
Hello Sanatan,Take a look at the created from me sample. In selection changed event the new value is showing the key instead of the text.