We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Access child rows from parent row

Thread ID:





5491 Jul 5,2003 02:15 AM UTC Jul 5,2003 09:05 AM UTC WinForms 2
Tags: GridControl
Asked On July 5, 2003 02:15 AM UTC

Helo agaian, Just a little thing :) Suppose I have a hieratical Databound grid, and that the current cell is part of a parrent row. The node can be expanded or not. Is it possible to check among the child rows belonging to the current parent row (the one that the mouse is over - holding the current cell) and see if one of the child columns holds a special value. More precise. I have a boolean value column in the child grid. I want to pop-up a message if a user tries to delete the parent row and at least one of the child rows has this boolean value set to true. I need help only for accessing child rows from the parent rows... Can you help me ?

Administrator [Syncfusion]
Replied On July 5, 2003 06:39 AM UTC

Currently, as far as the GridDataBoundGrid goes, the child lis does not exist until the parent node is expanded. So, from the GridDataBoundGrid point of view you cannot get at the child list if it is closed. So, since you need access whether or not the parent row is expanded, then you will have to use the relation to access the child list. Here is some code that you could try:
//dSet is the DataSet being used...
private void ListChildrenOfGridRow(int gridRowIndex)
	GridBoundRecordState rs = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(gridRowIndex);
	if(rs.LevelIndex >= dSet.Relations.Count)
		DataRelation relation1 = dSet.Relations[rs.LevelIndex];
		string childColName = relation1.ChildColumns[0].ColumnName;
		string parentColName = relation1.ParentColumns[0].ColumnName;
		int parentPos = rs.Position;
		string parentValue = ((DataRowView)rs.Table[parentPos]).Row[parentColName].ToString();
		string filter = string.Format("[{0}] = '{1}'", childColName, parentValue);
		DataView dv = new DataView(relation1.ChildTable, filter, "", DataViewRowState.CurrentRows);
		foreach(DataRowView drv in dv)
			DataRow dr = drv.Row;
			Console.WriteLine("{0}, {1}, {2}", dr[0], dr[1], dr[2]);

Replied On July 5, 2003 09:05 AM UTC

Thanks again Clay. The code worked. You are amazing :)


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon