user189756 user189756 - 1 year ago 551
ASP.NET (C#) Question

ASPxGridView - How to get the Selected Row in a Detail Grid of a Master-Detail GridView?

Can anyone explan how I can access the selected row of a detail grid in a DevExpress master-detail ASPxGridView? I've found an example on the devexpress support website But I can't get it tow ork, I'm working with version 11 of DevExpress.

Thanks in advance.

Answer Source

I found a way to get the selected row of the detail grid, not sure how 'advised' it is to do it this way but it works fine for me, I added an onload() event to the detail grid and then I was able to access that instance of the gridview by casting it to an ASPxGridView.

Here is my Code, the detail grid:


                <dx:ASPxGridView ID="detailGrid" runat="server"   DataSourceID="SqlDataSource2" 
                    Width="100%" OnBeforePerformDataSelect="detailGrid_DataSelect" 

and then I handle the onoad() event like this:

ASPxGridView gridView;
protected void detailGrid_Load(object sender, EventArgs e)

    gridView = sender as ASPxGridView;
    gridView.SelectionChanged += new EventHandler(gridView_SelectionChanged);


So I just made a ASPxGridView instance of the detail grid, and now I can make use of its SelectionChanged() event.

private static int invoiceID;

    void gridView_SelectionChanged(object sender, EventArgs e)
        invoiceID = Convert.ToInt64(gridView.GetSelectedFieldValues("InvoiceID")[0]);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download