Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Combo box with foreign key in Datagrid

Reply
Thread Tools

Combo box with foreign key in Datagrid

 
 
Rob Edwards
Guest
Posts: n/a
 
      10-22-2003
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.


 
Reply With Quote
 
 
 
 
Jacob Yang [MSFT]
Guest
Posts: n/a
 
      10-23-2003
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/de...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/is...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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hibernate foreign key as primary key Lionel Java 9 08-10-2011 04:58 PM
How to reference one combo box from another combo box SM Javascript 2 04-28-2007 04:49 PM
Survey - implementing CRUD with "foreign name" instead of foreign key. H5N1 ASP .Net 0 05-03-2006 11:36 PM
Fill Combo Box based on another Combo Box dthmtlgod ASP General 1 11-16-2005 04:08 PM
Datagrid - foreign key values - replace ID with name Bryon Brewer ASP .Net Datagrid Control 0 07-26-2003 04:06 AM



Advertisments