Bart
Tue Nov 15 06:45:48 CST 2005
Hi,
"Sowen Cheung" <sowenlist@shaw.ca> wrote in message
news:ujWGd%23Z6FHA.1420@TK2MSFTNGP09.phx.gbl...
> Hello
>
> How can I bind a column's value to another table?
>
> All tables are in the dataset already, I just have two tables and I bind
> table1 to the datagrid
>
> eg)
>
> table1
> column....,level_id, level2_id,...
>
> level_id is a FK to table2,
>
> I want to show the level_name instead of level_id.
>
> How can I show table2's level_name according to each record's level_id?
You can add a relation between the two table's and then use expression
columns to resolve the foreign key. It's important to remember that the
lookup table (table2 here) is the parent table.
Suppose you have a DataSet ds with two tables:
ds.Relations.Add( "rel1",
ds.Tables["table2"].Columns["level_id"],
ds.Tables["table1"].Columns["level_id"] );
// add resolved foreign key
ds.Tables["table1"].Columns.Add("level_name", typeof(string),
"Parent(rel1).level_name");
HTH,
Greetings
>
> Thank you very much!
>
> --
> Best Regards!
> Sowen Zhang
>
http://com.angGoGo.com
>
http://www.angGoGo.com
>
http://biz.angGoGo.com
>