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.Teacher s = tlTeachers;
Code like this works:
Label1.Text = Profile.Teacher s.Count.ToStrin g(); // The number of items in
the profile object
Label1.Text = Profile.Teacher s[1].FirstName.ToSt ring();// The value of an
item at a particular index position
But this does not:
GridView1.DataS ource = Profile["Teachers"]; // Populate the GridView1 from
the Profile Object
GridView1.DataB ind();
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.Teacher s = tlTeachers;
Code like this works:
Label1.Text = Profile.Teacher s.Count.ToStrin g(); // The number of items in
the profile object
Label1.Text = Profile.Teacher s[1].FirstName.ToSt ring();// The value of an
item at a particular index position
But this does not:
GridView1.DataS ource = Profile["Teachers"]; // Populate the GridView1 from
the Profile Object
GridView1.DataB ind();