bind data to gridview using custom data class?

G

Guest

I have Custom Data class which stores data about single customer and then i
store that customer objects in arraylist as shown below.

Customer custdata = null; // Custom Data class for 1 customer data.

ArrayList ar = new ArrayList(); // To store more than one customer
object.
for (int x = 0; x < 30; x++)
{
custdata = new Customer();
custdata.CustomerID = 1234 + x;
custdata.CustomerName = "Name" + x.ToString();
custdata.CustomerLocation = "UK " + x.ToString();
custdata.CustomerType = x.ToString();

ar.Add(custdata);

}

grid.; /// FEW Steps are missing and not sure to make it compatable to Grid.
grid.DataBind();

Now i want to bind data to gridView control, just like as we do if it was
Datatable.
Is there any simple conversion possible?

I do not want to use DataSet or DataTable but collection of Customer Objects
in Arraylist.

Thanks in advance.


-Vineet
 
C

Cor Ligthert [MVP]

VineetBatta,

If you want to use the arraylist instead from a normal performing solution
without troubles, than why are you asking for help to us.

Do you think that I want my name with a non good solution on internet?

It sounds for me the same as I want to increase a number but I want to use
the divide operator.

Cor


"vineetbatta" <[email protected]> schreef in bericht

(e-mail address removed)...
 
O

Otis Mukinfus

I have Custom Data class which stores data about single customer and then i
store that customer objects in arraylist as shown below.

Customer custdata = null; // Custom Data class for 1 customer data.

ArrayList ar = new ArrayList(); // To store more than one customer
object.
for (int x = 0; x < 30; x++)
{
custdata = new Customer();
custdata.CustomerID = 1234 + x;
custdata.CustomerName = "Name" + x.ToString();
custdata.CustomerLocation = "UK " + x.ToString();
custdata.CustomerType = x.ToString();

ar.Add(custdata);

}

grid.; /// FEW Steps are missing and not sure to make it compatable to Grid.
grid.DataBind();

Now i want to bind data to gridView control, just like as we do if it was
Datatable.
Is there any simple conversion possible?

I do not want to use DataSet or DataTable but collection of Customer Objects
in Arraylist.

Thanks in advance.


-Vineet
Vineet,

Which version of the framework are you using? If you are using 2.0, take a look
at BindingList<T> for your list object, IEditableObject and
INotifyPropertyChanged interfaces for your custdata class. You can find
information about how to use these interfaces in the .NET 2.0 documentation.

A good book about databinding is "Data Binding With Windows Forms 2.0" by Noyes.
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 
O

Otis Mukinfus

VineetBatta,

If you want to use the arraylist instead from a normal performing solution
without troubles, than why are you asking for help to us.

Do you think that I want my name with a non good solution on internet?

It sounds for me the same as I want to increase a number but I want to use
the divide operator.

Cor


"vineetbatta" <[email protected]> schreef in bericht

(e-mail address removed)...
Cor,

Perhaps you should also read the book mentioned in my answer to Vineet's post.
Your post, besides being aggressive and rude, sounds as though you missed that
particular part of learning about data binding.
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 
C

Cor Ligthert [MVP]

Otis,

It was just in the style of your question.
I do not want to use

Did my reply sound rude, than I succeeded in what I wanted to show you.

Cor
 
O

Otis Mukinfus

Otis,

It was just in the style of your question.


Did my reply sound rude, than I succeeded in what I wanted to show you.

Cor

The original post was not mine, so you originally did not answer my question.
However it's interesting that you admit your intention was to be rude. Not very
good behavior for a MVP my friend.
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 

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