Combo box with foreign key in Datagrid

R

Rob Edwards

Two tables: Employee, Salary

I want to be able to update the Salary information with the dates and
changes to each employee in a datagrid.

The EmployeeID is the foreign key in the Salary table.

OK... so I created a datagrid with the datasource being the Salary table.
I converted the EmployeeID column into a template column.
The datasource of that column is the employee table
The DataTextField is the name of the employee
The DataValueField is the EmployeeID

In DataBindings I have bound the SelectedValue to the EmployeeID in the
Salary table.

I fill the data adapter in:

If not Page.IsPostBack
daSalary.Fill(DsSalary1)
daEmployee.fill(DsEmployee1)

The problem is the same name is displayed in each of the rows (that being
the value of the first row returned).

How do you return the different SelectedValue for each row in the datagrid?

Thanks.
 
J

Jacob Yang [MSFT]

Hi Rob,

I am sorry if there is any misunderstanding but I am not sure about the
exact meaning of "How do you return the different SelectedValue for each
row in the datagrid?". Please clarify it more detailed.

In addition, I have found some related articles regarding this issue for
your reference.

Creating Custom Columns for the ASP.NET Datagrid
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
/creatingcustomcolumns.asp
"...
Next I need to convert this sample over to use a live table from the
database. ShipVia is a foreign key to the lookup table "Shippers," which
I'll assign as the DataSource to our DropDownColumn in the code..."

Managing Hierarchical Inserts in ASP.NET and ADO.NET
http://msdn.microsoft.com/msdnmag/issues/03/07/DataPoints/
"...
The key ingredient in building hierarchical applications is to create
related DataTable objects within a DataSet. This sample application relies
on the relationship between the orders and their order detail records for
displaying the values and for updating the values to the database. To
establish this symbiosis, a DataRelation object is created and set up to
link the orders DataTable and the order details DataTable. If a relation is
created on a field that is already a foreign key to the same parent table,
the relation will use the existing foreign key..."

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top