views:

550

answers:

1

There are a lot of master/detail databinding examples with detail form on the same window than the master, I can't find any example where detail is in a new window.

Do you know any example in C# or at least in VB.NET ?

+1  A: 

I don't know of an example, but this should be simple enough to do. You didn't specify if this is for WinForms or ASP.Net, so here is how to do both.

In WinForms, you would create the form for the child records and add a public function that accepts the primary key of the master record and uses it to get all children.

Public void ShowChildRecord(int RecordId)
{
// databinding logic here using the recordID to retrieve the child's data.

}

So in the form that has the parent record, assuming you're using a DataGrivView, in the SelectedIndexChanged event handler, you'd have the following.

ChildForm f = new ChildForm();
f.ShowDialog(this);
f.ShowChildRecord();

A similar problem could be solved in ASP.Net by having the child page take the RecordID as a QueryString parameter and doing the databinding to the child record in the Page_Load event. Then on the Master data page you would have a repeater with this in the ItemTemplate:

<a href='<%# DataBinder.Eval(Container.DataItem, "RecordId")' Target="_ChildRecords">View child record</a>
David Stratton
One tiny quibble with this otherwise excellent answer: if the child will only be used to show one detail and then be closed, make the recordId a ctor argument.
tpdi
Thank you, it's the answer I expected.
programmernovice