The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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
ADAdministrator Syncfusion Team 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.
DCdan carrAugust 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