PC Review


Reply
Thread Tools Rate Thread

Binding Combobox in Datagrid to ArrayList

 
 
Michael C#
Guest
Posts: n/a
 
      21st Mar 2005
I have found a few samples of using a combobox in a Datagrid on the Web
(Windows Forms). While these examples work well for what they do, I need
more functionality, and I'd like some advice on the best way to implement it
(if it hasn't already been implemented, that is)...

Here's my situation:

-I have an ArrayList of Items that need to be bound to the combobox. The
ArrayList contains data like this:

1, Green
3, Yellow
7, Red

-The underlying Datagrid field should display the text value but the numeric
value will actually be written back to the database.

I've been trying to come up with the best way to do this, and so far my
ideas mostly entail adding a property to the class being used to implement
the combobox in datagrid, and setting it to the numeric value of the
selected combobox item. My other option was to load the lookup table values
into Hashtables of the form:

htColor ("Green") = 1
htColor ("Yellow") = 3
htColor ("Red") = 7

And then retrieve the Hashtable values before writing back to the database.
Because of design requirements, the Datagrid is *not* bound to the
Datasource - it is populated via a DataTable generated at run-time.

I just wanted to make sure I was on the right track here, if anyone knows of
this being done somewhere already (I'm sure I'm not the first person to
encounter this), or if I'm way off base with this one and obviously
insane...

Thanks.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding an ArrayList to a datagrid Doug Microsoft ASP .NET 4 8th Nov 2006 03:19 PM
DataGrid and ArrayList binding kids_pro Microsoft C# .NET 2 17th Oct 2005 01:16 PM
Binding DataGrid To ArrayList Rami Microsoft VB .NET 5 6th Feb 2005 09:54 PM
ArrayList - DataGrid binding Jordan Microsoft C# .NET 1 13th Nov 2003 04:59 PM
Binding a datagrid to an arraylist Piyush Microsoft Dot NET Framework Forms 0 20th Oct 2003 09:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:51 AM.