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

[Solved] Access master table datakey from detail table

2 Answers 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rich
Top achievements
Rank 1
Rich asked on 15 Apr 2009, 03:17 PM
I'm sure I'm missing something stupid but I've been staring at this for too long . . .

I have a two-level hierarchical grid: invoices and shipments that are associated with each invoice.  In the ItemCreated event for the grid I'm setting properties for a HyperLink column which will call a JavaScript funtion to open a shipment detail window.  One parameter for this function is a piece of information (approvalStatus) that exists at the MasterTableView level rather than the DetailTables level.  My efforts to retrieve this value have so far proven fruitless.  

Any pearls of wisdom?  Thank you in advance.

protected void grdInvoices_ItemCreated(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridDataItem)  
        {              
            //String approvalStatus = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["INVOICE_ID"].ToString();              
            if (e.Item.OwnerTableView.Name == "DetailTable")  
            {  
                HyperLink viewLink = e.Item.FindControl("ViewLink") as HyperLink;  
                viewLink.Attributes["href"] = "#";  
                viewLink.Text = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["shipment_id"].ToString();  
                viewLink.Attributes["onclick"] = string.Format("return ShowProbillWindow('" + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["shipment_id"] + "', '" + approvalStatus + "');");                  
            }  
        }  
            } 

 

2 Answers, 1 is accepted

Sort by
0
Rich
Top achievements
Rank 1
answered on 15 Apr 2009, 07:05 PM
Problem solved, in at least some way.  I just included the master table field in the detail table query. 

I don't know why I have to make things more complicated than they need to be, although I can see where this might not always be a possible solution.

Thanks,
Rich
0
Shinu
Top achievements
Rank 2
answered on 16 Apr 2009, 04:07 AM
Hi Rich,

Even though your problem is solved I would suggest you to refer the following help article which explains how to access parent key value from Detail table.
Extracting primary key value for parent item in hierarchy on Update/Insert

Shinu
Tags
Grid
Asked by
Rich
Top achievements
Rank 1
Answers by
Rich
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or