How add column to IEnumerable or grid it's bound to?

  • Thread starter Thread starter Ronald S. Cook
  • Start date Start date
R

Ronald S. Cook

I bring back a list of Employees as an IEnumerable of Employee... columns
include EmployeeId, EmployeeLastName, etc.

I want to bind the IEnumerable to a datagrid BUT I want the grid to have an
extra column, a checkbox for the user to select some employees and not
others.

I will then use this information, but the checkbox column does not
correspont to a column in the Employee table to get updated.

Is there a way I can add a column to an IEnumerable? What is a "normal" way
to do what I'm trying to do?

I can convert the IEnumerable to a DataTable and add a column to it and then
bind to the datagrid, but that seems like a hack.

Thanks for any help,
Ron
 
Well, I tend to stay away from the DataGrid control - however as far as I
know when binding directly to an object collection it creates the grid based
on the object you're using. Just add a boolean property to your Employee
object with a get and set accessor. When the user modifies the checkbox in
the column, the object in your collection will be updated as well.

If this solution does not work for you, we need more information how your
data layer is setup when you're persisting data from your application back
to the database.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top