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

Master/Slave ComboBox - Strange Behavior

Hi,

I have implemented two ComboBox cells in my datagrid as suggested in the documentation. The master combo is populated from DataTable with string type for display and integer type for value. Once selected the integer value is set as a value of the datagrid cell while string is displayed.

Once the slave combo in the same row is dropped the integer value from the master is used to query SQL database and populate DataTable with an integer and a date converted to string column. The DataTable is bound to the slave combo using code below and that seems to work.

The issue is that once the slave combo is dropped down and a value selected datagrid displays the integer (i.e. the value column) and not a date (i.e. the display column).

Has anybody experienced this issue and if so what could be the remedy? Thanks

private void dg_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{


GridCurrentCell cc= dg.CurrentCell;

if (cc.ColIndex == 2)
{
//get DataTable from SQL here
DataTable dt = ...

GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;

cr.ListBoxPart.DataSource = dt;


}

}

3 Replies

HA haneefm Syncfusion Team June 1, 2007 05:38 PM UTC

Hi Adi,

In your slave combox column, you can set the style.DisplayMember to be the name of the column in the slave table that you want to see displayed in the grid, and set style.ValueMember to be the name of the column in the slave table that has values that match the values originally displayed in the grid column.

[c#]
this.gridDataBoundGrid1.DataSource = ds.Tables["Orders"]; //Primary key table.
this.gridDataBoundGrid1.Binder.InternalColumns["EmployeeID"].StyleInfo.DataSource = ds.Tables["Employees"]; //Slave key table.
this.gridDataBoundGrid1.Binder.InternalColumns["EmployeeID"].StyleInfo.DisplayMember = "FirstName"; //display the name in a primary key table for Slave key column.
this.gridDataBoundGrid1.Binder.InternalColumns["EmployeeID"].StyleInfo.ValueMember = "EmployeeID"; //slave key column name in a primary key table.
this.gridDataBoundGrid1.Binder.InternalColumns["EmployeeID"].StyleInfo.CellType = "ComboBox"; //Make it as a comobo box cell.

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

Best regards,
Haneef


AD Adi June 6, 2007 04:08 PM UTC

Hi,

I regret to say that the code provided did not work. For some reason when the value is slected in a dropdown the displayed text in the grid reverts to an integer value instead of remaining a date. Any other ideas?


HA haneefm Syncfusion Team June 6, 2007 11:29 PM UTC

Hi Adi,

Thank you for your update.

I am really sorry to inform you that I am not able to reproduce the issue in Essential version V4.4 with VS.Net 1.1/2.0. Maybe I am not following the steps that you are doing. Is it possible for you to upload us a minimal sample to reproduce the issue here? This will help us to analyse the issue further.

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon