Home All Groups Group Topic Archive Search About
Author
8 Dec 2005 8:46 PM
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

--
bf001removet***@abovetheline.biz

Author
14 Dec 2005 3:06 PM
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


Show quoteHide quote
"BJF" wrote:

> 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
>
> --
> bf001removet***@abovetheline.biz
>
>
>