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

Location of current row in grid with nested relations...

How could I locate the current row in my DataTable if the current table is not the root table in a nested relation?

4 Replies

AD Administrator Syncfusion Team December 9, 2003 07:26 AM

I tried this(from a class derived from GridDataBoundGrid): CurrencyManager cm = (CurrencyManager)BindingContext[this.DataSource, "NameOfTableInNestedRelation"]; int index = cm.Position; This is only working if the DataMember is the name of the root table of the DataSet.


AD Administrator Syncfusion Team December 9, 2003 08:10 AM

It is not too easy to get the position in the original table, but it is pretty straight forward to retrieve tbe item itself. Below is some code. If you need the position, then you could try to find the retrieved item in the table somehow.
private void button1_Click(object sender, System.EventArgs e)
{
	GridCurrentCell cc = grid.CurrentCell;
	GridBoundRecordState rs = grid.Binder.GetRecordStateAtRowIndex(cc.RowIndex);
	DataRowView drv = rs.Table[rs.Position] as DataRowView;
	Console.WriteLine(drv[0].ToString() + " -- " + drv[1].ToString());
}


AD Administrator Syncfusion Team December 10, 2003 02:16 AM

Thanks!! Now I have the row index in the source table. (I compared the drv.Row with each row in the DataTable object...) Is there also a way to get the column index? I did not find a way.


AD Administrator Syncfusion Team December 10, 2003 02:40 AM

Try this: int field = this.grid.Binder.ColIndexToField(cc.ColIndex);

Loader.
Live Chat Icon For mobile
Up arrow icon