PC Review


Reply
Thread Tools Rate Thread

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

 
 
Ronald S. Cook
Guest
Posts: n/a
 
      23rd Jun 2008
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

 
Reply With Quote
 
 
 
 
Jeff Winn
Guest
Posts: n/a
 
      24th Jun 2008
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.

"Ronald S. Cook" <(E-Mail Removed)> wrote in message
news:4DAE8C11-455A-4745-9707-(E-Mail Removed)...
>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
>


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How add row to grid bound to IEnumerable(Of Employee)? Ronald S. Cook Microsoft C# .NET 1 15th Apr 2008 04:07 PM
how do i use the sql mobile resultsetview to set column names for a bound data grid? Joanne Microsoft Dot NET Compact Framework 6 15th Jun 2007 07:04 PM
Can a grid column bound to a DateTime be null? Thirsty Traveler Microsoft ASP .NET 1 17th May 2006 04:07 PM
How do you alternate images in a data bound column of a data grid control? C Newby Microsoft ASP .NET 7 2nd Apr 2004 06:00 PM
Setting Bound Grid Column Width Tim Nelson Microsoft C# .NET 2 24th Feb 2004 01:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:34 PM.