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
close icon

GridDataBoundGrid ComboBox Question

I am setting a grid's datasource as follows: grid.DataSource = oDataTable; This works great. Columns and rows filled out. When I try to hook up the combobox droplist like this: grid.Model.ColStyles[colIndex].DataSource = oNewDataTable; grid.Model.ColStyles[colIndex].DisplayMember = "sDispMember"; grid.Model.ColStyles[colIndex].ValueMember = "sValMember"; then the data from the original datasource is no longer displayed in the cells. Also, after making a selection from a combobox list and moving to another cell, the cell changes from the displaying the selection to being empty again. Also, am I correct in thinking the method I'm using above for setting the combobox list will set all cells in the specified column? Does something like grid[row, col].DataSource set the combobox list for a specific cell? Thanks.

4 Replies

AD Administrator Syncfusion Team January 22, 2003 07:02 PM UTC

For a GridDataBoundGrid, you cannot use indexers to specify style properties for individual cells (other that the Text/CellValue property that is mapped back to your datasource). The reason is there is no storage to hold such properties in a griddataboundgrid. So, you cannot just set the DataSource for an individual cell. To set styles for columns in a GridDataBoundGird, the preferred way would be to either add GridBoundColumns for each column, and then use the StyleInfo member of the GridBoundColumn to set these column properties. Or, if you do not add GridBoundColumns, you can use the internal columns, GridDataBoundGrid.Binder.InternalColumns, and set the style properties in its StyleInfo member for each column.


KJ Kenneth Johnson January 23, 2003 11:12 AM UTC

I'm now adding the GridBoundColumn's for each column in my DataTable, but getting the same results. When I do not try to bind a an ArrayList as the datasource for the combo list, the data is displayed in the grid. When I try to set the combo list datasource, the grid data is not displayed in the cells. I'm using the following code. for (int i=0; i

KJ Kenneth Johnson January 23, 2003 12:03 PM UTC

I think I found my problem. The column is defined as type string, the DisplayMember being assigned is a string type, but the ValueMember I am assigning is an int. When I drop the assignment of the int ValueMember, everything is as expected. However, I need to keep track of the string displayed to the user and the underlying integer code assigned to the string. Any suggestions on how I can accomplish this?


AD Administrator Syncfusion Team January 23, 2003 09:00 PM UTC

Hi Ken, the combobox will try to save the integer value from the ValueMember into the column. That means your underlying datatable must accept this value. Make sure the column in your oDataTable is of type int and that the ValueMembers of the displayed foreign table are valid values for the underlying column from oDataTable. Stefan

Loader.
Live Chat Icon For mobile
Up arrow icon