Re: Gridview, bind column to property of nested type
Ron Young <[email protected]> Wed, 30 Jan 2008 10:50:22 -0600
| Newsgroups | gmane.comp.windows.devel.dotnet.web |
|---|---|
| Message-ID | <[email protected]> |
Disregard. It was my list<t> initialization code. -----Original Message----- From: Discussion of building .NET applications targeted for the Web [mailto:[email protected]] On Behalf Of Ron Young Sent: Wednesday, January 30, 2008 10:34 AM To: [email protected] Subject: [DOTNET-WEB] Gridview, bind column to property of nested type Given the following: Class UserRole { Public string RoleName { get; set; } Public string Description{ get; set; } Public override string ToString(){ return RoleName; } } Class MyUser { Public UserRole Role{ get; set; } Public string FirstName{ get; set; } } I want to bind a list of MyUser to a gridview, and one of the columns in the gridview should display the RoleName of the user. I thought overriding ToString() in UserRole would do the trick but I get a NullReferenceException. I know my code to generate a List<MyUser> is correct. Here's the bound field for that role column in the gridview: =================================== This list is hosted by DevelopMentor? http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com