Question : Access control inside nested gridview

Hello experts,

I have a gridview nested within a gridview.


   


Within Gridview 2 I have a linkbutton which has an event and on that event I would like to get access to it's parents gridview key value.

So for instance this usually works if the gridview is not nested like attached (below).

So I think what is needed is to get the row's parent (which is gridview2) and go from there. So my question is how can I get access to gridview2 using the code below?

Thanks

Code Snippet:
1:
2:
3:
4:
5:
6:
7:
protected void LinkButton1_Click(object sender, EventArgs e)
    {
        LinkButton lb1 = (LinkButton)sender;
        GridViewRow row = (GridViewRow)lb1.NamingContainer;
        
        long intOrderItemId = Convert.ToInt64(GridView2.DataKeys[row.RowIndex].Value);
    }

Answer : Access control inside nested gridview

You should get like this

GridView Gridview2 = (GridView)row.Parent;
Random Solutions  
 
programming4us programming4us