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.

MappingName in GridDataBoundGrid

Thread ID:





70943 Jan 9,2008 11:46 AM Jan 9,2008 12:00 PM Windows Forms 1
Tags: GridControl
Asked On January 9, 2008 11:46 AM

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 ???


haneefm [Syncfusion]
Replied On January 9, 2008 12:00 PM

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.

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,


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.