Re: DataRelations and DataGrids
From: aualias (aualias_at_newsgroups.nospam)
Date: 09/21/04
- Next message: TusharP: "How to apply scrollbar to form having border style none"
- Previous message: Edward: "binding combobox"
- In reply to: Sijin Joseph: "Re: DataRelations and DataGrids"
- Next in thread: Jeffrey Tan[MSFT]: "Re: DataRelations and DataGrids"
- Reply: Jeffrey Tan[MSFT]: "Re: DataRelations and DataGrids"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 21 Sep 2004 09:53:12 -0400
Hi Sijin,
I am still confused as to how this is used with a DataGrid. For example, if
I have two tables and want to display the data (forget about editing for
now):
Table1
name (char)
descriptionFK (int)
Table2 - lookup
id (int)
description (char)
Create the DataSet with the two tables - oDataSet.
Create a DataRelation LookupToMain.
Call dataGrid1.SetDataBindings(oDataSet, "Table1");
How do I display the description field as a column in the DataGrid that
displays data from Table1?
Are there any examples that you know of?
This cannot be difficult. I'm missing something here...
Thanks.
Alfredo
"Sijin Joseph" <sijinNOSPAMdotnet@hotmail.com> wrote in message
news:#d42774nEHA.2340@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> Yes you can use a DataRelation for this purpose, you will need to define
> a DataRelation between your parent tables and child tables and then use
> the DataColumn.Expression property to set the value to the
> ParentRelations relevant field.
>
> This is the relevant documentation from the MSDN documentation of
> DataColumn.Expression property
>
> PARENT/CHILD RELATION REFERENCING
>
> A parent table may be referenced in an expression by prepending the
> column name with Parent. For example, the Parent.Price references the
> parent table's column named Price.
>
> A column in a child table may be referenced in an expression by
> prepending the column name with Child. However, because child
> relationships may return multiple rows, you must include the reference
> to the child column in an aggregate function. For example,
> Sum(Child.Price) would return the sum of the column named Price in the
> child table.
>
> If a table has more than one child, the syntax is: Child(RelationName).
> For example, if a table has two child tables named Customers and Orders,
> and the DataRelation object is named Customers2Orders, the reference
> would be:
>
> Avg(Child(Customers2Orders).Quantity)
>
>
> Also check out these articles
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatinglookuptableforlistboxorcomboboxcontrol.asp
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbwlkCreatingLookupTableOnData-BoundWindowsForm.asp
>
> Sijin Joseph
> http://www.indiangeek.net
> http://weblogs.asp.net/sjoseph
>
> aualias wrote:
> > I have tables Junk and JunkLookup in a DataSet. Junk has an integer
field
> > junkType, which is a primary key into JunkLookup.
> >
> > Can I bind to Junk and use a DataRelation to display and update data in
a
> > DataGrid?
> > Is it better to do a join in the SQL?
> >
> > Ideally, I would like to copy the database relationships in the DataSet
that
> > I use on the client.
> >
> > Thanks.
> >
> > Alfredo
> >
> >
> >
- Next message: TusharP: "How to apply scrollbar to form having border style none"
- Previous message: Edward: "binding combobox"
- In reply to: Sijin Joseph: "Re: DataRelations and DataGrids"
- Next in thread: Jeffrey Tan[MSFT]: "Re: DataRelations and DataGrids"
- Reply: Jeffrey Tan[MSFT]: "Re: DataRelations and DataGrids"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|