Master Detail w Multiple Keys

Discussion in 'ASP .Net Web Controls' started by BJF, Dec 8, 2005.

  1. BJF

    BJF Guest

    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

    --
    BJF, Dec 8, 2005
    #1
    1. Advertising

  2. BJF

    Tom Guest

    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


    "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
    >
    > --
    >
    >
    >
    >
    Tom, Dec 14, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGVtZXRyaQ==?=

    Master - Detail Examples

    =?Utf-8?B?RGVtZXRyaQ==?=, Oct 19, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    671
    Saravana [MVP]
    Oct 20, 2003
  2. Doug McCann
    Replies:
    1
    Views:
    1,006
    William Brogden
    Aug 5, 2004
  3. asmj
    Replies:
    0
    Views:
    501
  4. Arun Kumar Menon

    Master Detail detail

    Arun Kumar Menon, Aug 6, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    197
    Arun Kumar Menon
    Aug 6, 2003
  5. Frederik Borg

    ASp.net data binding: Master-detail-detail

    Frederik Borg, Jun 9, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    355
    Frederik Borg
    Jun 9, 2006
Loading...

Share This Page