- Home
- Forum
- ASP.NET Web Forms (Classic)
- Data Binding with MultiSelection DropDown
Data Binding with MultiSelection DropDown
Hi,
I am using a multi-selection drop-down and trying to bind it at run-time. Everything seems to be working fine except one. The values appearing in the list are proper but when I select a value, its corresponding id is being displayed in the text.
I have used the following code:
mddlIncludeExcludeCargoType.DataSource = cargoTypeList;
mddlIncludeExcludeCargoType.DataValueField = CargoType.Binding.CargoTypeId;
mddlIncludeExcludeCargoType.DataTextField = CargoType.Binding.CargoTypeName;
Can anyone suggest why this is happening?
I am using a multi-selection drop-down and trying to bind it at run-time. Everything seems to be working fine except one. The values appearing in the list are proper but when I select a value, its corresponding id is being displayed in the text.
I have used the following code:
mddlIncludeExcludeCargoType.DataSource = cargoTypeList;
mddlIncludeExcludeCargoType.DataValueField = CargoType.Binding.CargoTypeId;
mddlIncludeExcludeCargoType.DataTextField = CargoType.Binding.CargoTypeName;
Can anyone suggest why this is happening?
SIGN IN To post a reply.
3 Replies
RS
Rajarajeswari S
Syncfusion Team
January 24, 2008 08:59 AM UTC
Hi,
Thanks for using Syncfusion products.
I am able to reproduce the issue that you have mentioned, this is because of, you have given different field names for DataTextField and DataValueField.
DataTextField - Field in the data source which provides the item Text.
DataValueField - Field in the data source which provides the item Value.
If you wants to have both to be same you have bind these properties with same fields. Please refer the below code snippet which illustrates this:
this.MultiSelectionDropDown1.DataSource = dt;
this.MultiSelectionDropDown1.DataTextField = "Value";
this.MultiSelectionDropDown1.DataValueField = "Value";
this.MultiSelectionDropDown1.DataBind();
Please refer the sample from the below link which illustrates this:
http://websamples.syncfusion.com/samples/Tools.Web/6.1.0.34/I40893/main.htm
Please let me know if this helps you out.
Regards,
Raji
SS
Saurabh Srivastava
January 24, 2008 09:19 AM UTC
Hi,
Thanks for your reply. But if we take a generic ASP.NET drop-down control, the two properties are provided so that the "Text" property is used to show actual "text" in drop-down while "value/id" property is used to bind each text data with its underlying id/value for internal processing.
Same should be the case with Syncfusion Multiselection Drop-down otherwise, there is no point of having two properties - DataTextField and DataValueField.
Thanks,
Saurabh
Thanks for your reply. But if we take a generic ASP.NET drop-down control, the two properties are provided so that the "Text" property is used to show actual "text" in drop-down while "value/id" property is used to bind each text data with its underlying id/value for internal processing.
Same should be the case with Syncfusion Multiselection Drop-down otherwise, there is no point of having two properties - DataTextField and DataValueField.
Thanks,
Saurabh
RS
Rajarajeswari S
Syncfusion Team
January 28, 2008 08:40 AM UTC
Hi Saurabh,
Thanks for using Syncfusion products.
We have analyzed your issue and suspect this as a defect. Could you please follow the incident # 40893 to get more details on this issue.
Please let me know if you have any other concerns.
Regards,
Raji
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
-
SA saurabh
- Jan 23, 2008 07:35 AM UTC
- Jan 28, 2008 08:40 AM UTC