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

binding usercontrol to GridDataBoundGrid

Hi,
I am binding a dataset to GridDataBoundGrid control.
One of the columns in the grid includes cells ,and inside each of these cells there is a usercontrol.
These usercontrols also need to be bound to the data.
How can I add usercontrols to the cells
and bind data to them?
Thanks.


1 Reply

RC Rajadurai C Syncfusion Team December 12, 2008 12:47 PM UTC

Hi Shimon,

Thanks for your interest in Syncfusion products.

To add the user control to grid and make use of it. Please follow these steps.
1) Create a model and a renderer class deriving from GridGenericCellModel and GridGenericCellRenderer classes respectively with properties to be made available.

2) Add this control to the cellmodels of griddataboundgrid as,

this.gridDataBoundGrid1.Model.CellModels.Add("MyComboBox", new ComboCellModel(this.gridDataBoundGrid1.Model));

Here, "MyComboBox" denotes the name of the usercontrol and ComboCellModel is the class created deriving from GridGenericCellModel.

3) Add the usercontrol to the respective cell.

How to add usercontrol to the cell
*******************************************
To provide the entire grid have the same usercontrol.

this.gridDataBoundGrid1.TableStyle .CellType = "MyComboBox";
this.gridDataBoundGrid1.TableStyle. CellValue = "One";
.......


To provide usercontrol to the specified cells, handle the PrepareViewStyleInfo event in griddataboundgrid.

if(e.RowIndex ==1 && e.ColIndex == 2)
{
e.Style.CellType = "MyComboBox";
e.Style.CellValue= "One";
------
}


Regards,
Rajadurai


Loader.
Live Chat Icon For mobile
Up arrow icon