This is a migrated thread and some comments may be shown as answers.

Relating Grids with a composite key?

1 Answer 169 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Byron
Top achievements
Rank 1
Byron asked on 29 Jan 2009, 04:08 PM
How do you relate two grids in a master/detail arrangment when you have a composite key? I was trying to use the same technique that is used in the Telerik trainer "RadGrid Related Tables" session, by simply adding the additional field to the where clause on the select for my details table, but doing this does not return any records in the details grid. So the select looks like this

SELECT 
    [PrcsName], 
    [MsgCode], 
    [MSGBody], 
    [ToEmailAddress], 
    [FromEmailAddress], 
    [EmailSubject], 
    [EmailAttachmentName], 
    [MailHost], 
    [SendEmailCode]
FROM [EsmEmailInfo]
WHERE 
    (([PrcsName] = @PrcsName) AND ([MsgCode] = @MsgCode))

I know the relationship/data is valid (the composite key is PrcsName + MsgCode) as I can do a straight join using the same criteria and get back all the data I need. If I use a single column from the composite key, it'll return data to the detail grid, but it doesn't return the results I want,,,I get too much data back.

If I have a set of tables with a single field making up the primary/foreign key, it works great, but so far when I've tried to use a composite key it doesn't work. Is there another way I should solve this?

Thanks,
Byron (telerik newbie)

1 Answer, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 02 Feb 2009, 03:50 PM
Hi Byron,

You can utilize the SelectedValues array of the grid when having a composite key which defines the master/detail relation. Review the code snippets from the following online demo for more info.

Best regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Byron
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or