The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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!
ADAdministrator Syncfusion Team 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);
}