BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hello,
I have a project that display tabular data with SfDataGrid and have include a Combobox column which allows user to select from a predefined list. The Combobox has different datasource.
The problem I have is that when Combobox ValueMember is set different field other the DisplayMember it does not work, e.g
loc.ValueMember = "LocId";
loc.DisplayMember = "LocationName";
The above code block works but the one below does not work
loc.ValueMember = " LocationName ";
loc.DisplayMember = "LocationName";
But my requirement is that I want LocId(ValueMember) to be set by customer selecting LocationName(DisplayMember) from the Combobox .
Please find below relevant sections of the code
GridComboBoxColumn declaration:
GridComboBoxColumn loc = (GridComboBoxColumn)sfDespatch.Columns["StockLocation"];
loc.DataSource = StockLocationLookups;
loc.ValueMember = "LocId";
loc.DisplayMember = "LocationName";
DataSource:
public List
StockLocationLookup class:
public class StockLocationLookup
{
[Display(Name = "No")]
public int LocId { get; set; }
[Display(Name = "Location Name")]
public string LocationName { get; set; }
}
Thanks in advance for your usual assistance.
Hi Paul,
We have checked the reported scenario with the provided details. We suspect that the reported issue occurs because of the type mismatch. By default, the ValueMember should be the same type as the Mapping name. When the type gets mismatched this kind of problem occurs. Here, we have attached a sample like your scenario, please have a look at this. If you still facing the reported issue, please modify the attached sample based on your scenario. It will be helpful for us to check on it and provide you with a solution at the earliest.
Regards,
Dhanasekar M.
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Hello Dhanasekar,
Thanks for the prompt response. I will implement your suggestion and revert to you with feedback
Best regards,
Paul Aziz