Custom Object used with Profile Object
-
I have a custom object that inherits from CollectionBase and it does not successfully bind to GridViews or DropdownLists. My understanding is that that is because GridViews and Dropdownlists implement IEnumerable, therefore, if I want my custom object to bind to the gridview or the dropdownlist, I need to inherit from IEnumerable also, right? Whatever the answer is, I'm trying to learn what I need to do to get my custom object to bind to a gridview and a dropdownlist. I don't think this has anything to do with it, but I'm setting the value of a Profile object (ASP.NET 2.0) equal to the custom object. School.Teachers tlTeachers = new School.Teachers(); tlTeachers.Add(new School.Teacher("Buck")); Profile.Teachers = tlTeachers; Code like this works: Label1.Text = Profile.Teachers.Count.ToString(); // The number of items in the profile object Label1.Text = Profile.Teachers[1].FirstName.ToString();// The value of an item at a particular index position But this does not: GridView1.DataSource = Profile["Teachers"]; // Populate the GridView1 from the Profile Object GridView1.DataBind();