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

GDBG: Retrieve the RowIndex given the primary key of the underlying DataSource

Thread ID:

Created:

Updated:

Platform:

Replies:

44988 Jun 8,2006 08:54 AM UTC Jun 9,2006 06:21 AM UTC WinForms 2
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On June 8, 2006 08:54 AM UTC

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

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On June 9, 2006 06:21 AM UTC

Hi Haneef, Thank you for your help. Using DataView.Find works fine for me. Regards Wolfgang

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

;