473,385 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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

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
0 1931

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: A Traveler | last post by:
Hi, I have a custom collection class i wrote, LineItemsCollection, which is a strongly typed collection of objects of my LineItem class. The LineItem class is a simple class with just a couple...
0
by: Giorgio | last post by:
It seems that the ASP.NET Microsoft team didn't think about this!! The profilemanager class has the following methods: - DeleteInactiveProfiles. Enables you to delete all profiles older...
0
by: a | last post by:
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...
6
by: npaulus | last post by:
Hi, DataSets are usually resource heavy. Instead of having to pass them from my middle tier to my presentation layer I was wondering if anyone has developed a custom collection object that is...
0
by: Tommaso Caldarola | last post by:
I have a custom collection of custom objects. I bind a DataGrid with collection1, a property of custom object is a ReferenceType (another custom object). For that property in the datagrid I...
3
by: cannontrodder | last post by:
I am displaying names and other details of my users in a Formview control by binding my custom business object to it. My custom object also has a property that is a collection of boolean values and...
2
by: Peter Afonin | last post by:
Hello, I'm using CreateUserWizard control in ASP.NET 2.0. I'm storing the data in SQL Server 2005. The first and last steps run smoothly without any problems. But I added one middle step to...
9
by: Kirk | last post by:
I have successfully, implemented a custom Membership Provider to a SQL 2000 table, however, I am having problems doing the same with a Profile Provider. As I understand it, the steps for both of...
0
by: Pieter | last post by:
Hi, I'm using NHibernate 1.2 (CR1), and I'm using a custom list (inherited from BindingList(Of T) ) for all my lists. The NHibernate documentation told me that I had to implement...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.