Wednesday, March 21, 2012

Populating a datagrid ... how is it done normally?

Hi All ...
I'm writing a small shopping cart app (school assignment) and need to list
all the books that a user selects.
I have created a "BookBasket" object that contains among other things an
arraylist of the user selected books. The "book" object contains isbn,title
price and quantity information.
I'd like to display the contents of the BookBasket in a datagrid control.
I assume that to start with I'd have to iterate through the basket to
identify each books information, but then how do I populate the datagrid
from there?
It seems from what I've read,that it is easier to populate a datagrid from a
datasource, but I don't know how that would relate to what I'm doing.
any clues or links to examples would be much appreciated.
Thanks in advance
Prime.Prime,
There is a plethora of examples on using a datagrid control. Search
google and you will find more than you need. The second article outlines
what kind of datasources a datagrid will accept, an array is a valid data
source so you won't have to write any code to fill another control. The
third snippit supports my last statement.
Hope this helps.
Jared
Here's one to get you started
http://samples.gotdotnet.com/quicks...c_datagrid.aspx
http://msdn.microsoft.com/library/d...nadodataset.asp
You can bind to the following structures if their elements expose public
properties:
a.. Any component that implements the IList interface. This includes
single-dimension arrays
"Prime" <not@.real.address> wrote in message
news:uIhFN$0pEHA.1668@.TK2MSFTNGP14.phx.gbl...
> Hi All ...
> I'm writing a small shopping cart app (school assignment) and need to list
> all the books that a user selects.
> I have created a "BookBasket" object that contains among other things an
> arraylist of the user selected books. The "book" object contains
> isbn,title
> price and quantity information.
> I'd like to display the contents of the BookBasket in a datagrid control.
> I assume that to start with I'd have to iterate through the basket to
> identify each books information, but then how do I populate the datagrid
> from there?
> It seems from what I've read,that it is easier to populate a datagrid from
> a
> datasource, but I don't know how that would relate to what I'm doing.
> any clues or links to examples would be much appreciated.
> Thanks in advance
> Prime.
>
>
Hi Jared,
I think you've helped me before ... thank-you again.
I found the gotdotnet sample very helpful. We are currently using a text
book that is poor by any standard so your assistance is very much
appreciated.
The second sample was good, but we're not allowed to use a database
interface! I originally coded my app that way,but was told that it was
unacceptable. :( I found the database version extremely simple to code.)
Again, thanks for you assistance.
Prime.
"Jared" <ask_me_for_it@.nospam.com> wrote in message
news:10lpaldc1uahra6@.corp.supernews.com...
> Prime,
> There is a plethora of examples on using a datagrid control. Search
> google and you will find more than you need. The second article outlines
> what kind of datasources a datagrid will accept, an array is a valid data
> source so you won't have to write any code to fill another control. The
> third snippit supports my last statement.
> Hope this helps.
> Jared
> Here's one to get you started
>
http://samples.gotdotnet.com/quicks... />
agrid.aspx
>
http://msdn.microsoft.com/library/d...nadodataset.asp
> You can bind to the following structures if their elements expose public
> properties:
> a.. Any component that implements the IList interface. This includes
> single-dimension arrays
> "Prime" <not@.real.address> wrote in message
> news:uIhFN$0pEHA.1668@.TK2MSFTNGP14.phx.gbl...
list
control.
from
>

0 comments:

Post a Comment