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.
Unfortunately, activation email could not send to your email. Please try again.

Finding the correct record

Thread ID:

Created:

Updated:

Platform:

Replies:

74644 Jun 23,2008 05:11 PM Jun 27,2008 12:12 PM ASP.NET Web Forms (Classic) 2
loading
Tags: GridGroupingControl
Administrator [Syncfusion]
Asked On June 23, 2008 05:11 PM

Hello,

I need to get the correct record from a cell but offsets are making this difficult. For example:

protected void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
int rowIndex = e.Style.TableCellIdentity.RowIndex;
Record rec = this.GridGroupingControl1.Table.Records[rowIndex];
}

The above method has a fault: Rows containing column names or filterbar dropdowns etc, will add to the rowIndex.

What then is the best way to get a RowIndex from the cell? I need a method that is guaranteed to match the grid's RowIndex to the underlying DataTable's RecordIndex?

I could manually adjust the RowIndex (such as "e.Style.TableCellIdentity.RowIndex - 3") ... but then I am assuming the offset is always a fixed constant. Rather I need to find out at runtime how many rows are adding an offset and use that information to get the correct DataTable record.

Thanks,
Robert Claypool, Nashville, TN



Murali Samanthapudi
Replied On June 27, 2008 12:11 PM

Hi Robert,

Thank you for using our libraries.

Inside QueryCellStyleInfo, you can get the underlying record object directly from the TableCellIndentity. You do not have to find indexes and then index another collection to get the record object. Here is some code showing how you can use the TableCellIdentity to get at the underlying data.

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
GridRecord record = e.TableCellIdentity.DisplayElement.GetRecord() as GridRecord;
if (record != null)
{
//to get the raw dataobject, ie the DataRowView from a DataTable datasource
//you can use
object data = record.GetData();
DataRowView drv = data as DataRowView;
if (drv != null)
{
//Console.WriteLine("field0={0} field1={1}", drv[0], drv[1]);
}
}
}


Please let us know if this is not the information you needed.

Regards,

Clay Burch


Administrator [Syncfusion]
Replied On June 27, 2008 12:12 PM

That is exactly what I needded. Thanks!


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.

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.

;