Home All Groups Group Topic Archive Search About

bind data to gridview using custom data class?

Author
16 Oct 2006 6:07 AM
vineetbatta
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

Author
17 Oct 2006 4:24 AM
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" <vineetba***@discussions.microsoft.com> schreef in bericht
news:06355C9

5-7AD9-4628-9D0F-F80CD9704***@microsoft.com...
Show quote
>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
Author
17 Oct 2006 10:59 AM
Otis Mukinfus
On Tue, 17 Oct 2006 06:24:32 +0200, "Cor Ligthert [MVP]"
<notmyfirstn***@planet.nl> wrote:

Show quote
>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" <vineetba***@discussions.microsoft.com> schreef in bericht
>news:06355C9
>
>5-7AD9-4628-9D0F-F80CD9704***@microsoft.com...
>>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
>
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
Author
17 Oct 2006 5:44 PM
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

Show quote
"Otis Mukinfus" <ph***@emailaddress.com> schreef in bericht
news:pld9j2pkgdusetgu0mnl847q76auq8baku@4ax.com...
> On Tue, 17 Oct 2006 06:24:32 +0200, "Cor Ligthert [MVP]"
> <notmyfirstn***@planet.nl> wrote:
>
>>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" <vineetba***@discussions.microsoft.com> schreef in bericht
>>news:06355C9
>>
>>5-7AD9-4628-9D0F-F80CD9704***@microsoft.com...
>>>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
>>
> 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
Author
17 Oct 2006 10:23 PM
Otis Mukinfus
On Tue, 17 Oct 2006 19:44:19 +0200, "Cor Ligthert [MVP]"
<notmyfirstn***@planet.nl> wrote:

Show quote
>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
>
>"Otis Mukinfus" <ph***@emailaddress.com> schreef in bericht
>news:pld9j2pkgdusetgu0mnl847q76auq8baku@4ax.com...
>> On Tue, 17 Oct 2006 06:24:32 +0200, "Cor Ligthert [MVP]"
>> <notmyfirstn***@planet.nl> wrote:
>>
>>>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" <vineetba***@discussions.microsoft.com> schreef in bericht
>>>news:06355C9
>>>
>>>5-7AD9-4628-9D0F-F80CD9704***@microsoft.com...
>>>>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
>>>
>> 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
>

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
Author
17 Oct 2006 10:55 AM
Otis Mukinfus
On Sun, 15 Oct 2006 23:07:02 -0700, vineetbatta
<vineetba***@discussions.microsoft.com> wrote:

Show quote
>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

AddThis Social Bookmark Button