Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Unable to get a Profile custom (object) collection to bind to GridView,etc (IList objects)?

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

Scheduled Pinned Locked Moved C#
csharpasp-netdatabasehelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kloepper
    wrote on last edited by
    #1

    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: 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); } } -- modified at 14:35 Friday 10th February, 2006

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups