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

Getting Parent Key

2 Answers 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nicholas Walker
Top achievements
Rank 1
Nicholas Walker asked on 23 Jul 2008, 08:04 PM
These seems like it should be simple, but for some reason I can not figure out how to do it.  I am handling the ItemCommand event of a hierachial self-referening grid.

I simply need to get the key of the item where the add new record button was clicked.

For example

Item 1
    Add new Record
    Sub Item 1
       Add new Record
Item 3
    Add new record
    Sub Item 2
       Add New Record


If I click on the Add new record button under Item 1, I need to get the key/value of Item 1.

If I click on Add new record under Sub Item 1, I need to get the key/value for Sub Item 1.

Seems like a simple thing, but I can't seem to get it.

2 Answers, 1 is accepted

Sort by
0
Nicholas Walker
Top achievements
Rank 1
answered on 23 Jul 2008, 10:30 PM
I figured it out.

 Dim p As GridDataItem = e.OwnerTableView.ParentItem
x = p.OwnerTableView.DataKeyValues(p.ItemIndex)("CampaignCriteriaID")
0
Shinu
Top achievements
Rank 2
answered on 24 Jul 2008, 05:50 AM
Hi Nicholas,

You can also refer the follwing help document link which explains how to access the Primar Key value for the parent item.
Extracting primary key value for parent item in hierarchy on Update/Insert

Shinu.
Tags
Grid
Asked by
Nicholas Walker
Top achievements
Rank 1
Answers by
Nicholas Walker
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or