I have added a ComboBoxColumn to my DataGrid and am attempting to get it to display the field description text but have an integer value stored in the underlying field. Standard dropdown stuff...
It is however, displaying the integer value by default on load. If I edit a row and choose a different Category from the list, it WILL display the description on exiting the cell.
Grid DataSource field that holds the ComboBox column value:
public int Category { get; set; }
Grid Column:
<ComboBoxColumn Field="Category" DataSource="productCategoryList" TextField="Name" Width="100" />
Combobox DataSource:
(code to load the list is not shown)
public List<ProductCategory> productCategoryList;
public class ProductCategory{ public int CategoryId { get; set; } public string Name { get; set; }}
I tried using the ValueField="CategoryId" in the ComboBoxColumn field but got the error "The name 'CategoryId' does not exist in the current context." What am I missing?
Thanks
Hello Michael,
I attached a sample demonstrating how to use the ValueField property. Let me know if you have any questions.
column-types.zip