Master Detail w Multiple Keys

B

BJF

My goal is to have a master/detail setup with the master being a GridView,
and the detail being either a DetailsView or a FormView. I've gotten this
to work as long as the relationship between the two controls only relys on
one key field ( the datasource has a 'where' clause with only one field in
it).

I need two keys from the GridView table to control what shows up in the
detail control. I've set the GridView to use a table that has a two-field
primary key (TAPENO and RECORDING), and both fields show up in the
DataKeyNames property of the GridView. When I create the datasource for the
FormView control, I set the 'where' clause to request two fields. The
wizard generates two lines in the WHERE clause text box:
SQL Expression: Value:
[TAPENO] = @TAPENO
GridView1.SelectedValue
[RECORDING] = @RECORDING GridView1.SelectedValue

When I run the application, the FormView control shows no contents when I
select an item from the GridView (master) control. I know the FormView is
showing up, there some HTML for it as a table, but no rows or fields.

Like I said, I've been able to do this in a one-key-field scenario, but not
in a two-key-field scenario.

Any suggestions?

Ben
 
T

Tom

Ben,

I'm having the same problem. I ran a SQL trace using SQL Server Profiler
and found the problem. The select statement for the DetatilsView is wrong.
In my case the first key is CatalogNumber=000001 and the second key is
LotNumber=200533001. When I look at the trace the SQL statement looks like
this:

exec sp_executesql N'SELECT CatalogNumber, CatalogName, PONumber, Vendor,
VendorLotNumber, VendorGrade, LotNumber, Quantity, UofM, DateReceived,
Location, DateEntered, PreviouslyApprovedLot, CofAIncluded, Quantity2, UofM2
FROM LotData WHERE (CatalogNumber = @CatalogNumber) and LotNumber =
@LotNumber', N'@CatalogNumber nvarchar(6),@LotNumber nvarchar(6)',
@CatalogNumber = N'000001', @LotNumber = N'000001'

As you can see, the LotNumber is set to the same value as the CatalogNumber.
I haven't found the solution yet but I will continue to work on it.

Tom
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top