popiandro popiandro - 1 year ago 175
Javascript Question

Checking if a aspxgridview Master-Detail has any row checked in Client Side

I need to check if there is any row checked in a Master-Detail AspxGridView.

With the master I can use


But how can I check it with the detail rows using JS?

Thanks in advance

Answer Source

to accomplish this you need to assign a unique ClientInstanceName to each detail grid and then access that particular detail grid on client side using the assigned ClientInstanceName, which in turn should include the master's grid row ID part, ie detailGrid_1 for the first row, detailGrid_2 for the second and so on.

To assign the ClientInstanceName to each detail grid you need to add a custom Page_Init handler to the detail grid as the set ClientInstanceName in that handler in codebehind.

So, the web definition may look like:

<dx:ASPxGridView ID="masterGrid" runat="server" ClientInstanceName="masterGrid">
      <dx:ASPxGridView ID="detailGrid" runat="server" OnInit="detailGrid_OnInit">

Then in codebehind:

protected void detailGrid_OnInit(object sender, EventArgs e) {
    ASPxGridView detailGridView = (ASPxGridView)sender;
    GridViewDetailRowTemplateContainer templateContainer =
    detailGridView.ClientInstanceName = string.Format("detailGrid_{0}",

Then on client side in your event handler (you didn't mention upon which event you were trying to check if detail grid has some rows selected) you need to obtain the master grid's row ID and construct a client instance name for your detail grid manually, e.g.:

eval('detailGrid_' + master_grids_row_id).

or you may pass it in a ready-made form to JS even handler like the article below suggests.

Once you have the correct detailGrid Client instance name you can call the following JS method:


See this DX support article for some code samples: https://www.devexpress.com/Support/Center/Question/Details/Q450479


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download