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

GridDataboundGrid: enumerating rows like in GridControl

Hi

Is it possible to enumerate the rows in a GridDataBoundGrid?
There are many examples where this is done in the GridControl but none with the GridDataboundGrid. ( For example in the Grid Performance Demo (Grid samples->Data Bound->Gird Performance Demo) the Virtual GridControl does have an enumerated column, the GridDataBoundGrid does not)

(As a workaround it would be possible to no longer display the first column, which is not actually bound but is always there, and add a custom column to display the numbers. However, this is a workaround a really dont like and I havent yet managed to hide that first column to select entire rows. )

It would be very nice if enumerating was possible with the GridDataboundGrid.

Greetings and thanks in advance

Daniel

3 Replies

NR Nirmal Raja Syncfusion Team August 13, 2010 12:23 PM UTC

Hi Daniel,

Thank you for your interest in Syncfusion products.

If want to iterate the rows through the events such as QueryCellInfo in GridControl, then you can use the PrepareViewStyleInfo which goes through the elements of the GridDataBoundGrid as row index and column index as the argument.

Please refer the sample attached in the below location:
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=RowBackColor2015614009.zip

Let me know if you have any queries.

Regards,
Nirmal


DK Dani Knopf August 13, 2010 03:48 PM UTC

Hi

Thanks a lot for your answer. Unfortunately, it does not work when i use the event as follows:

void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if(e.ColIndex==0)
{
e.Style.Text = e.RowIndex.ToString();
}

...

Only in the top row (header row) appears the correct number (0). The others remain empty.

What can I do about this?

Best regards.



NR Nirmal Raja Syncfusion Team August 16, 2010 01:06 PM UTC

Hi Daniel,

The event will provide only for the display cell and not the header cell. As the column index zero represent the column hader and if you need to have text in it then you have to change the header as static and then you can assign its value.

Please refer the code below:
void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if(e.ColIndex==0)
{
e.Style.CellType = "Static";
e.Style.Text = e.RowIndex.ToString();
}
}

Let me know if you have any queries.

Regards,
Nirmal

Loader.
Live Chat Icon For mobile
Up arrow icon