Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
0
Displaying ComboBox in Grid
posted

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