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 StockLocationLookups => _unitOfWork.StockLocations.GetStockLocationLookups().ToList();
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.