Solved

Filling DataGrid from collection class

Posted on 2004-10-28
199 Views
Last Modified: 2010-04-15
Hello again,

is it possible to fill a datagrid based on a collection class?

my collection class is inheriting from the DictionaryBase class.

thanks

0
Question by:brdrok
    7 Comments
     
    LVL 13

    Expert Comment

    by:dungla
    brdrok,

    MSDN said: "The data source must be an object that implements the System.Collections.IEnumerable interface"

    you can fill a datagrid based on a collection class which inheriting from the DictionaryBase class. Because DictionaryBase is the class implement IEnumerable interface.
    0
     
    LVL 7

    Author Comment

    by:brdrok
    Hey dungla....

    thanks for your feedback.  I can't seem to find "The data source must be an object that implements the System.Collections.IEnumerable interface".  Can you please provide a link.  

    The closest thing i saw was: "The following data sources are valid: Any component that implements the IList interface"

    However, from what I have gathered so far is that the "DictionaryBase" is implementing the following interfaces: ICollection, IEnumerable, and IDictionary. Does that mean, I am out of luck?  Does that mean I will have to declare my class like this:

    public class Employees : DictionaryBase, IList

    So many questions, and only so many hours in a day :)


    0
     
    LVL 7

    Assisted Solution

    by:NipNFriar_Tuck
    Hi brdrok, the answer to your question is yes.  The DictionaryBase inherits from ICollection, which is a parent of IList.  So you would need to include IList on your class definition and implement the needed functions for IList.
    0
     
    LVL 7

    Author Comment

    by:brdrok
    NipNFriar...

    thank you.  I have posted another question (400 pts) asking how to implement the Add method of the IList interface.  Can't seem to get it to work.  If you would like to take a crack at it, it should be there.  thanks

     
    0
     
    LVL 13

    Expert Comment

    by:dungla
    brdrock

    Here is the link in my MSDN July 2004

    ms-help://MS.MSDNQTR.2004JUL.1033/cpref/html/frlrfSystemWebUIWebControlsBaseDataListClassDataSourceTopic.htm

    The topic: BaseDataList.DataSource Property  [C#]
    0
     
    LVL 13

    Accepted Solution

    by:
    0
     
    LVL 7

    Author Comment

    by:brdrok
    thanks for the help.  i suppose creating a dataview is the way to go about this.  still was somehow hoping to implement the IList interface to my DictionaryBase collection class but appearantly I am still too dumb :(

    Was trying to ge the best of both worlds.  implement the IList so i can use it as a datasource for a datagrid, but I also like the key, value pair as well....  

    anywho......thanks for all your help you two....


    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Article by: Ivo
    C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    933 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now