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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Resolving a DataRow back to is GDBG position

Thread ID:

Created:

Updated:

Platform:

Replies:

25435 Feb 25,2005 10:27 PM UTC Feb 26,2005 12:00 AM UTC WinForms 1
loading
Tags: GridControl
Dave Butler
Asked On February 25, 2005 10:27 PM UTC

Given a particular DataRow (identified by primay key value), I''m attempting to determine its location in a GridDataBoundGrid (which is not display the primary key value). Here''s the code scenario: myTable.Columns["PrimaryKey"].ColumnMapping = MappingType.Hidden; myGrid.DataSource = dt; Now given: DataRow dr = dt.Rows.Find(pkValue); CurrencyManager cm = (CurrencyManager) grid.BindingContec[grid.DataSource, grid.DataMemeber]; DataView dv = (DataView) cm.List; Is there any hope of resolving the DataRow position in the grid given the available information? Applying a sort to the DataView and using the DataView.FindRow method is not an option, as the user can change the sort order (which must be preserved). Also, the columns being displayed in the grid do not necessarily have a column or combination of columns that are unique. Any help would be greatly appreciated!

Administrator [Syncfusion]
Replied On February 26, 2005 12:00 AM UTC

The only way I would know to find the row in the grid is to loop through cm.List looking for the primary key value from the DataRow you are seeking. //dr holds the DataRow to be found string pkCol = "Col1"; CurrencyManager cm = (CurrencyManager)this.gridDataBoundGrid1.BindingContext[this.gridDataBoundGrid1.DataSource, this.gridDataBoundGrid1.DataMember]; int i = 0; object pkValue = dr[pkCol]; foreach(DataRowView drv in cm.List) { if(drv[pkCol].Equals(pkValue)) break; i++; } if(i < cm.List.Count) { int gridRowIndex = this.gridDataBoundGrid1.Binder.PositionToRowIndex(i); Console.WriteLine("found at row {0}", gridRowIndex); }

CONFIRMATION

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.

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

;