Solved

How to add additional field to a gridview's data source, generic collection?

Posted on 2015-01-15
2
147 Views
Last Modified: 2015-01-15
Hi, I'm using vs2012
I have a List<UserPrincipal> objects that I set as the data source for my gridview control.  I am now asked to add an additional AD user object field that is not part of the class UserPrincipal fields.  How to add this additional field to the gridview or do I need to create a new dataset for this?

Thank you.
0
Comment
Question by:lapucca
2 Comments
 
LVL 20

Accepted Solution

by:
Daniel Van Der Werken earned 500 total points
ID: 40551697
Either create a new data set or create a new object for the generic list.

I generally manually create data sets and return them. This is an arduous task but it gives me more flexibility.

For a fast way, make a new object that encapsulates both:

public class MyUserPrincipal
{
   public UserPrincipal principal;
   public Object myOtherObject;
}

Open in new window


Now, pass the List<MyUserPrincipal> to the grid.
0
 

Author Closing Comment

by:lapucca
ID: 40551703
Such a smart and sleek solution!  Thank you.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question