Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
150
Not able to select child row from code behind
posted

Hello everybody,

I'm not able to set the selected state from code behind for a child row.

The following Statement is not working (ddgProduced is the Name of the grid):

 ddgProduced.GridView.Behaviors.Selection.SelectedRows.Add(ddgProduced.GridView.Rows[1].RowIslands[0].Rows[1]);

If I do the same for a master row it works:

ddgProduced.GridView.Behaviors.Selection.SelectedRows.Add(ddgProduced.GridView.Rows[2]);

Does anybody know this behavior? Is there an example for setting the selecting state of a child row in code behind?

 

Best reagrds

Kai

  • 7435
    Verified Answer
    Offline posted

    Hello Kai,

    Thank you for posting in our forums!

    In the WebHierarchicalDataGrid you can access the root ContainerGrid object by referencing the WebHierarchicalDataGrid control’s GridView property . Further, you can access a row’s child ContainerGrid objects by using the ContainerGridRecord object’s RowIslands property.Please note if you are using Load on Demand, make sure that the ContainerGrid exists; i.e, the parent row is expanded before trying to access the row island. There are several ways to select a row after enabling row selection: you can select a row by clicking on a cell in that row or you can also select rows in code by adding them to the selected rows collection.

    When you want to get the selected rows from the child grid, then you need to iterate through the grid’s row collection and access the current selected child bands through the RowIsland Selection Behaviors, I just modify the code statement you provided:

    ddgProduced.GridView.Rows[1].RowIslands[0]..Behaviors.Selection.SelectedRows.Add(ddgProduced.GridView.Rows[1].RowIslands[0]. Rows [1]);

    Please refer also to the following documentation article about the Selection behavior of the WebHierarchicaDataGrid

    http://help.infragistics.com/doc/ASPNET/2015.2/CLR4.0/?page=WebHierachicalDataGrid_Selection.html