By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,155 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

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

P: n/a
a
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
code----------------------------------------------------------------------------------

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" >
<properties>
<add name="Teachers"
type="School.Teachers"
allowAnonymous="true"/>
</properties>
</profile>
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
GridView1.DataBind();
The custom object:
"School.Teachers"---------------------------------------------

[Serializable()]
public class Teachers : CollectionBase
{
public Teachers()
{}
public Teacher this[int index]
{
set
{
List[index] = value;
}
get
{
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)
{
List.Remove(value);
}
public bool Contains(Teacher value)
{
return List.Contains(value);
}
}
Feb 10 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.