Ron Young
2008-01-30 16:34:18 UTC
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
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