MappingName in GridDataBoundGrid

Hey,
How can I create two gridBoundColumns that will have the same mapping name of the dataSource. I mean that I want to have two gridBoundColumns that will display the same data from a dataTable (and after that to configure for each one of them other rendered). The problem is that I can't configure more than one column with the same mappingName.

Haw can I do this ???

thanks,
Yoni


1 Reply

HA haneefm Syncfusion Team January 9, 2008 05:00 PM UTC

Hi Yoni,

You cannot have two columns with the same mapping name. But one way you can do this by adding an unbound column in a grid.

To do this, where you want the second column, add a GridBoundColumn with some unique mapping name, say "UProduct". (At this point, this will just display an empty column in that position in the grid.) To populate this column, add a grid.model.QueryCellInfo event handler. In the handler have code like this.

int colIndex = grid.Binder.NameToColIndex("UProduct");
if(colIndex == e.ColIndex && e.RowIndex > 0 && e.RowIndex < grid.Model.RowCount)
{
colIndex = grid.Binder.NameToColIndex("OrderID");
e.Style.CellValue = grid[e.RowIndex, colIndex].CellValue;
}

Please refer to the attached sample for implementation and let me know if this helps.
Unboundcolumn.zip

This should put th evalues from the real OrderID column into the "UProduct" column. In the code above the "&& e.RowIndex < grid.Model.RowCount" check is only needed if you have an AddNew row at the bottom of the grid.

Best regards,
Haneef



Loader.
Up arrow icon