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

CellType in GridDataBoundGrid

Hi,
I'm using a GridDataBoundGrid (Syncfusion 5.202.0.25).
The DataSource of the grid contains the Parent and the Children DataTables. It also contains a DataRelation between the 2 tables.
The Grid's Binder also contains this DataRelation.

In the grid, I see the following rows:

Parent1
Child1
Child2
Parent2
Child3
Child4
...

For the Parents and Children DataTables, I have 3 columns: Name, Value and Tag (Tag is hidden) + the column for the relation which is also hidden.

Until now, everything's fine.

I 'd like to have different cell types (Text, ReadOnly, ComboBox...) depending on :
- the nature of the row (Parent or Child)
- the data represented by the cell(which can be found in the Tag)

In order to do this, I've implemented the Model_QueryCellInfo event (as in your GDBGMultiHeader example) and I'm trying to set the gridQueryCellInfoEventArgs.Style.CellType.
However, I don't know how to get the DataTable Row corresponding to the cell for which Model_QueryCellInfo is being called.

Could you tell me how to do this or tell me if there is a better way to change the CellType depending on the data bound to it?

Thanks in advance
Mathieu


1 Reply

SR SubhaSheela R Syncfusion Team February 8, 2008 10:27 AM UTC

Hi Mathieu,

Thank you for using Syncfusion products.

1. There is no other possibility to set the cell type of the particular cell in GridDataBoundGrid. You can handle QueryCellInfo event to set cell types to the particular cell in GridDataBoundGrid using its CellType property.
2. You can retrieve the selected row by passing GridBoundDataGrid's DataSource and its DataMember to the BindingContext method of the GridBoundDataGrid and assign it to the CurrencyManager class object. Then typecasting this object to DataRowView object, you can get the selected record.
Below is the code snippet:


CurrencyManager cm = (CurrencyManager)BindingContext[gridDataBoundGrid1.DataSource, gridDataBoundGrid1.DataMember];
DataRowView drv = (DataRowView)cm.Current;
this.label1.Text = "ParentID:" + drv["parentID"].ToString() + " EmpID:" + drv["EmpID"].ToString() + " EmpName:" + drv["EmpName"].ToString() + "Quantity:" + drv["Quantity"].ToString() + "Price:" + drv["Price"].ToString();


Please refer the sample available in the link below and let me know if it helps:

http://websamples.syncfusion.com//samples/Grid.Windows/F71275S/main.htm

Regards,
Subhasheela R




Loader.
Live Chat Icon For mobile
Up arrow icon