How to adapt a class for the DataGrid...

G

Guest

Hi

I've written a class (in C#) which collects data from a remote server
Now, I'd like to make that data accesible from ASP.NET

My thought is to somehow bind my class to the DataGrid control.
I think that can be done by creating an adapter which adapts
my class, and then bind the adapter to the DataGrid

But, since I'm new to ASP.NET I don't know if I'm on the right track an
I don't know where to start..

Have any of you guys done or read something that does this

/To

PS. I do not wan't to save the collected data in a database or
xml-file. I'd like to make this adaptation in-memory only
 
G

Guest

I had a longer answer, but the MS posting is not working, my message got tossed and I have to write it over. I hate that

ADO.NET datasets. read about them in the MSDN Library and include data relations in your reading. They can provide rich solutions.
 
J

Jose Marcenaro

Hi Tom:

IMO, you are on the right track and the simplest way to implement that is to
make your class expose a property of type System.Collections.IEnumerable,
and then assign the DataGrid.DataSource property to it.
That way you can do the creation and all necessary initialization of your
object (i.e. connect to the remote source) and then just assign
dataGrid1.DataSource = myInstance.myData

See
http://msdn.microsoft.com/library/e...bcontrolsbasedatalistclassdatasourcetopic.asp
for an example (in this case a standard DataView is used as data repository,
but you may get your data on the fly instead)

Hope this helps, regards
Jose.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top