Re: Replacing key values with their referenced data records
From: Sijin Joseph (sijinNOSPAMdotnet_at_hotmail.com)
Date: 09/14/04
- Next message: Paul Smith: "Re: Problem with databinding"
- Previous message: matt parker: "Re: > > > > this statement occurs on thousands of other sites apart from google matt parker alias erickvan lintherzog@yahoo.com matt parker alias erick van lindt hout@yahoo.com matt parker alias erickvonlunsen@yahoo.com matt parker alias kimberleypar"
- In reply to: Wade: "Replacing key values with their referenced data records"
- Next in thread: Wade: "Re: Replacing key values with their referenced data records"
- Reply: Wade: "Re: Replacing key values with their referenced data records"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 14 Sep 2004 14:02:26 +0530
Hi Wade,
You need to search for Lookup values or Lookup tables. In .Net they are
set using the DisplayMember and ValueMember property of controls like
ComboBox, ListBox etc.
For the datagrid, 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
Wade wrote:
> I've been trying to solve this problem for several days, but I don't know
> what this operation is called, so I can't effectively search for a solution.
>
> I have a datagrid bound to a table I've imported from Access. The table is
> part of a relational database, so it has several columns containing foreign
> keys to related tables. In Access, the keys are replaced with the record
> that they reference in their respective parent tables. Each related record
> is a single string, so it simply replaces the key value in the column. This
> way, a user can change the string value without having to know the key (ID)
> of the data they are changing. I want to replicate this functionality in my
> VB .NET program, but I can't figure out how. Importing the tables and
> displaying the data isn't a problem, but I don't know how to relate the
> tables in the dataset and properly bind the datagrid to display the table the
> way I want it. Additionally, once I can get it to display properly, I need
> to be able to change a string value, and have the program locate the proper
> key value for the string so that key can be returned to the database. I've
> been told a solution is in the Resource Kit, but I haven't been able to find
> it. Any direction you can give me will be greatly appreciated.
- Next message: Paul Smith: "Re: Problem with databinding"
- Previous message: matt parker: "Re: > > > > this statement occurs on thousands of other sites apart from google matt parker alias erickvan lintherzog@yahoo.com matt parker alias erick van lindt hout@yahoo.com matt parker alias erickvonlunsen@yahoo.com matt parker alias kimberleypar"
- In reply to: Wade: "Replacing key values with their referenced data records"
- Next in thread: Wade: "Re: Replacing key values with their referenced data records"
- Reply: Wade: "Re: Replacing key values with their referenced data records"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|