Datatable for a multi valued column?

  • Thread starter Thread starter STom
  • Start date Start date
S

STom

I have a requirement to create a DataTable that relates to information on a
particular web screen. This wouldn't be too difficult except that one of the
fields is a multi-select listbox.

What is the best way to do this with a Datatable?

Thanks.

STom
 
STom said:
I have a requirement to create a DataTable that relates to information on a
particular web screen. This wouldn't be too difficult except that one of the
fields is a multi-select listbox.

What is the best way to do this with a Datatable?

Tom,
Sounds like a many-to-many relationship. How about using a intersection table?
e.g.
Entity1 table
Intersection table - contains the primary keys from both entity tables
Entity2 table

Then just fill in the multi-select listbox value(s) from Entity2 table using the
Intersection table.

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.able-consulting.com
 
Carl,

Yes, it is a many-to-many relationship.

What I am trying to find out though is how, programmatically, while I'm
building my table of values in ado.net, do I include this relationship and
its records.

STom
 
STom said:
Yes, it is a many-to-many relationship.
What I am trying to find out though is how, programmatically, while I'm
building my table of values in ado.net, do I include this relationship and
its records.

You can either find the corresponding record(s) manually by using the
DataTable.Rows Find method.
http://msdn.microsoft.com/library/e...systemdatadatarowcollectionclassfindtopic.asp

Or you can create a DataRelation between the DataTables at runtime,
http://msdn.microsoft.com/library/d...tml/frlrfsystemdatadatarelationclasstopic.asp
then transverse the relationships using the DataRow GetChildRows methods
to get the corresponding record(s).
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdatadatarowclassgetchildrowstopic.asp

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.able-consulting.com
 
Thanks Carl!

STom
Carl Prothman said:
You can either find the corresponding record(s) manually by using the
DataTable.Rows Find method.
http://msdn.microsoft.com/library/e...systemdatadatarowcollectionclassfindtopic.asp

Or you can create a DataRelation between the DataTables at runtime,
http://msdn.microsoft.com/library/d...tml/frlrfsystemdatadatarelationclasstopic.asp
then transverse the relationships using the DataRow GetChildRows methods
to get the corresponding record(s).
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdatadatarowclassgetchildrowstopic.asp

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.able-consulting.com
 
Back
Top