0

I have a Gridview with a select button. That select button causes a DetailsView to be created. I am using a custom DataBind method for the DetailsView. The custom DataBind method does call detailsview.DataBind() which then fires detailsview_ItemCreated. The EventArgs for detailsview_ItemCreated is empty.

I need to get the ID of the "parent" GridView.

detailsview_ItemCreated fires immediately after detailsview_DataBind() executes in the custom DataBind method so I'm not sure if I could add to EventArgs at some point or if I need to fire the method itself from the DataBind method. Or something else altogether.

Any help is appreciated

toadfromgrove
  • 143
  • 2
  • 14

2 Answers2

0

Try this inside the item created event which will give you the row index of the grid row.

int rindex=(((GridViewRow) (((DetailsView)(sender)).Parent.BindingContainer))).RowIndex
PraveenVenu
  • 8,217
  • 4
  • 30
  • 39
  • This would probably work, but my detailsview is not within my gridview. so .Parent returns the contentplaceholder or page – toadfromgrove Jan 19 '18 at 14:27
  • As it is not a parent child, when you bind itself, you have to keep it somewhere like session or something and check that when creating row item – PraveenVenu Jan 19 '18 at 21:22
0

Took a different approach and implemented the Page extension method in On postback, how can I check which control cause postback in Page_Init event then checked an IF for which GridView caused the postback

toadfromgrove
  • 143
  • 2
  • 14