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. Image for the cookie policy date
close icon

Getting 'NULL' Element

Hello,
I am using gridgrouping Control
I used element to get record.
But sometimes I got Null element when I clicked on the gridgrouping control row which gives me error for further code.
So is there any other way to get record?

Regards,
Rasika

3 Replies

SA Solai A L Syncfusion Team April 28, 2015 06:20 AM UTC

Hi Rasika,

Thank you for your interest in Syncfusion products.

We have analyzed your reported scenario. In order to get the record from a GridGroupingcontrol, you can use GridTableCellStyleInfo. Before fetching the record details using GetRecord, a validation is need to ensure the clicked cell is a record and the display element is not equal to null(this would resolve your problem of null reference exception).Please refer the below provided KB ,code snippet and sample for further clarification.

Code Snippet[c#]:

void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)

{

GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);

GridTableCellStyleInfoIdentity id = style.TableCellIdentity;

if (id.DisplayElement!=null && id.DisplayElement.Kind == DisplayElementKind.Record)//this is to validate whether the cell click is done only in value cells and not in headers/Caption row/anyother.

{

Record rec = id.DisplayElement.GetRecord();

MessageBox.Show("RowIndex is:" + rec.Id.ToString()); //Real RowIndex

}

}

Sample:

http://www.syncfusion.com/downloads/support/forum/118944/WindowsFormsApplication21_(2)755905147.zip

KB Link:

http://www.syncfusion.com/kb/4275/how-can-i-identify-a-record-from-the-gridstyleinfo


Note: If still your issue is not resolved. Please provide us a step by step replication procedure or replicate in the above provided sample and send back to us. So, that it would be easy for us to provide a prompt solution as early as possible.


Please let us know if you have any other concerns.


Thanks & Regards,

AL.Solai.



RA Rasika April 29, 2015 06:14 AM UTC

Hello,
Thank You so much for the reply.
Its working fine.Thanks a lot.

Regards,
Rasika


SA Solai A L Syncfusion Team April 29, 2015 07:38 AM UTC

Hi Rasika,

 

Thank you for your update.

 

We are glad to know that your issue has been resolved. Please let us know if you need any further assistance in future.

 

Thanks & Regards,

AL.Solai.


Loader.
Live Chat Icon For mobile
Up arrow icon