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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Populating ComboBox in DataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

32650 Aug 4,2005 11:24 PM UTC Aug 5,2005 02:20 PM UTC WinForms 2
loading
Tags: GridControl
dan carr
Asked On August 4, 2005 11:24 PM UTC

I have a ComboBox field in a datagrid which I want to hold a numeric value for but display a string. i.e. 1 = Stock 2 = Bond I want the combo box to display ''Stock'' but hold a value of 1. I have set the data member and value member properly. i.e. ValueMember=intSecType and DisplayMember=strSecType. The combobox is appearing with the correct contents. But, the grid is displaying the VALUE (1) not the DISPLAY (Stock). When I try to change the value I get an InvalidCastException error. Also, right after selecting a new value from the dropdown box the contents of the field are set to ''System.Data.DataRowView'' How can I resolve this issue? Thanks, Dan

Administrator [Syncfusion]
Replied On August 4, 2005 11:51 PM UTC

You need to set these properties: GridBoundColumn1.StyleInfo.ValueMember = "ValueCol" GridBoundColumn1.StyleInfo.DisplayMember = "DisplayCol" GridBoundColumn1.StyleInfo.CellType = "ComboBox" GridBoundColumn1.StyleInfo.DataSource = someOtherDataTable for the column you where you want the combobox. The someOtherDatTable is not the same as the grid.DataSource value. Also, the type of the ValueCol in someOtherDataTable must be teh same as the type of the combobox column in teh grid''s datasource. The \Syncfusion\Essential Studio\3.2.1.0\Windows\Grid.Windows\Samples\DataBound\GDBGcombos sample does this, and was completely done with teh designer. So, to see the code necessary to do this, look at the designer generated code in the sample.

dan carr
Replied On August 5, 2005 02:20 PM UTC

Thanks Clay--this works. One observation: If you set the DataSource (in the column collection editor) to the dataset name (without .table name)--then set the display/value member to table.fieldname it will NOT work. But, if you add the .table to the datasource (instead of before display/value member) it will work. i.e. must add the table name to the datasource not the display member. May help if the user were not given the option to select the wrong setup option. Thanks, Dan

CONFIRMATION

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.

Warning Icon 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.Close Icon

;