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.
Hi,
Is it possible to get the RowIndex for the current GDBG sorting given a specific DataRow (or a primary key) of the underlying data source?
Thanks in advance
Kind Regards
Wolfgang
ADAdministrator Syncfusion Team June 8, 2006 10:08 AM UTC
Hi Wolfgang,
If the data is sorted by primary key, you probably can use DataView.Find instead of just doing a linear search though the linear search is pretty efficient for simple look ups on small to medium sized tables.
private int FindSortedValue(int val)
{
int found = -1;
CurrencyManager cm = this.gridDataBoundGrid1.BindingContext[this.gridDataBoundGrid1.DataSource, this.gridDataBoundGrid1.DataMember] as CurrencyManager;
if(cm != null)
{
DataView dv = cm.List as DataView;
for(int i = 0; i < dv.Count; ++i)
{
if(dv[i][this.idCol].Equals(val))
{
found = i;
break;
}
}
}
return found;
}
//To get the RowIndex of the databound grid , you need to use this code. Here is a code snippet.
this.gridDataBoundGrid1.Binder.PositionToRowIndex( FindSortedValue(int.Parse(this.textBox1.Text)))
Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GDBG_UniqueID_8f986ed3.zip
Let me know if this helps,
Best Regards,
Haneef
ADAdministrator Syncfusion Team June 9, 2006 06:21 AM UTC
Hi Haneef,
Thank you for your help. Using DataView.Find works fine for me.
Regards
Wolfgang