Jump to content
Software FX Community

Children Grids


jvwiv

Recommended Posts

I have a child grid that I want to add a record to.  The parent grid uses a unique key counter field that I need to pass into the child grid during record addition.  I'm utilizing the following code to retrieve the ukid...

Protected Sub Grid2_ItemInserting(ByVal sender As Object, ByVal e As GridFX.WebForms.GridItemInsertingEventArgs)

Dim mod1 As IPQ = New IPQDim seqno As Int16

Dim ukid As Int16

ukid = Grid1.SelectedItems(0).DataValues.PrimaryKey.ToString

seqno = mod1.GetNextIPQNumber(ukid)

e.DataValues.Item("ukid") = ukid

e.DataValues.Item(

"Sequence") = seqno

End Sub

The issue is that the ukid is not necessarily related to the grid record I'm working with.  If I simply click on the + button to expand the child grid (grid2), the parent record that was used does not become the selected record and the ukid is not from the record that I'm adding. 

For example, record number 1 is currently selected. 

Click on the + button of record number 2 to show the children, click on the add button of grid # 2 and add the value.  Run thru the code above and you'll see that the ukid is from record number 1, not record # 2. 

However, if I click on record number 2, then the + button, the selected UKID is that of record #2. 

How can I get the correct results? 

 

 

post-5010-13922406109009_thumb.jpg

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

So you need the item from Grid1 that contains the Grid2 object that is inserting data, correct?  In that case, replace the "Grid1.SelectedItems(0)" with "((Grid)sender).ParentGridItem"

This takes the "sender" parameter, which is the Grid2 that is inserting, and gets its parent item, which is simply Grid.ParentGridItem.  That should fix it

Thanks!

post-2986-13922406126586_thumb.png

Link to comment
Share on other sites

John,

Is that a complier error?  The "sender" parameter in the event handler should be a Grid instance.  Maybe try doing "dim insertingGrid as Grid = sender".  Then call  "insertingGrid.ParentGridItem.DataValues.PrimaryKey.ToString()".  That should work.

Steve

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...