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 : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Identify row in grid based on key in database

Thread ID:

Created:

Updated:

Platform:

Replies:

82332 Jun 9,2009 04:55 PM UTC Jun 13,2009 11:27 AM UTC WinForms 3
loading
Tags: GridControl
Mark Kenner
Asked On June 9, 2009 04:55 PM UTC

I have some validation in the business layer of my application. If it fails for a row in the database I will get an exception in the UI layer along with the value of the key for the row in the data that had the problem.

So from the UI I have a GDBG and a string which is the key to the offending row. The key is NOT stored in the grid. I think I need to do the following:

1. Use the key to identify the row in the underlying datalayer.
2. Then find the row in the GDBG for the row in the datalayer.
3. Move focus to that row (I don’t need help with that part)

I am having trouble making this work. Could you please provide an example.

Thank You


Jisha Joy [Syncfusion]
Replied On June 11, 2009 09:25 AM UTC

Hi Mark,

If you are having record index of the underlying datasource, you could try using the ListManagerPositionToRowIndex method.This is used to find the row index within the grid from the row index within the data source.

this.gridDataBoundGrid1.Binder.ListManagerPositionToRowIndex(index);

Please let me know if this helps.

Regards,
Jisha

Mark Kenner
Replied On June 11, 2009 05:15 PM UTC

Thanks for the reply.

I have tried ListManagerPositionToRowIndex. It worked untill I sorted the grid. After a sort it would still return the same value (where the row in the grid would have been if the grid was not sorted). Am I missing a step?

I can always put the key in the grid and hide it but I think there must be a better way.


Rajadurai C [Syncfusion]
Replied On June 13, 2009 11:27 AM UTC

Hi Mark,

Thanks for your update.

Please try the following code.

CurrencyManager cm = (CurrencyManager)this.BindingContext[this.gridDataBoundGrid1.DataSource, this.gridDataBoundGrid1.DataMember];
int pos = this.gridDataBoundGrid1.Binder.PositionToRowIndex(0);
DataRow dr = ((DataRowView)cm.List[pos]).Row;
Console.WriteLine(dr[0].ToString());

This code retrieves the data value of the first column from the underlying row position. There is no other direct way found to get the position of underlying row after sorting in griddataboundgrid.It has to be handled through some code manually.

Regards,
Rajadurai

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

;