471,354 Members | 1,537 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Unable to get a Profile custom (object) collection to bind to Gri.

Q. Unable to get a Profile custom (object) collection to bind to
GridView,etc (IList objects)?

This is my first custom object so I may be doing something rather simple,
wrong, or it may be something else to do with the Profile object. Either
way, I need help

Here's a brief description of the

1) I have a custom object: "School.Teachers" (see below)

2) which is used as a Profile object data type in the web.config file:

<profile defaultProvider="AspNetSqlProfileProvider" >
<add name="Teachers"
3) 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;
4) 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
5) But this does not:

GridView1.DataSource = Profile["Teachers"]; // Populate the GridView1 from
the Profile Object
The custom object:

public class Teachers : CollectionBase
public Teachers()
public Teacher this[int index]
List[index] = value;
return (Teacher)List[index];
public int Add(Teacher value)
return List.Add(value);
public int IndexOf(Teacher value)
return List.IndexOf(value);
public void Insert(int index, Teacher value)
List.Insert(index, value);
public void Remove(Teacher value)
public bool Contains(Teacher value)
return List.Contains(value);
Feb 10 '06 #1
0 1789

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by A Traveler | last post: by
6 posts views Thread by npaulus | last post: by
reply views Thread by Tommaso Caldarola | last post: by
3 posts views Thread by cannontrodder | last post: by
9 posts views Thread by Kirk | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.