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

DataBoundGrid: rebind datasource.

Hello ! I have databound control and one column has drop down style. But the problem is to display for user in drop list only values, that weren''t yet entered as values in the column. My idea is to re-initialize datasource just before user opens drop-down list. So, I want to ask following 2 quesions: 1) When is the better place to re-calculate and re-bind datasource. (what event handler) 2) And how to enumerate values (actually strings) already entered in the column. Thanks.

5 Replies

AD Administrator Syncfusion Team August 18, 2004 05:08 AM UTC

You can use the CurrentCellShowingDropDown event to set values into a droplist. If you have a list of strings you want to use as the drop values, then you can use a StringCollection object and set it as the ChoiceList property of the cell style. Here is a sample that changes the ChoiceList shown in column 2 based on the value set in column 1 using CurrentCellShowingDropDown. You can see other choicelist usage in the Grid\Samples\CellTypes\ComboBoxes sample. There is also a KB on dynamic combobox lists though it uses DataTables and not choicelists. http://www.syncfusion.com/Support/article.aspx?id=567


AD Administrator Syncfusion Team August 18, 2004 07:25 AM UTC

Right, but I want to avoid showing in drop down list values, that were already entered in the table. So, the problem could be solved by enumeration of values, that already in the table.


AD Administrator Syncfusion Team August 18, 2004 07:43 AM UTC

You are free to build your list in CurrentCellShowingDropDown in any manner you care to. If you want to go through the column in the grid and remove values from your droplist that are already in the grid, you can do so. Of course, this may mean that your droplist could be empty depending on exactly what is displayed in the grid column and what was originally in your droplist. The main point is that in CurrentCellShowingDropDown, you can dynamically provide what droplist you want to see. How you construct this list is up to you.


AD Administrator Syncfusion Team August 19, 2004 12:49 AM UTC

Hello ! Ok, I''ve done the necessary fuctionality. Thank you. One small question here: After selection of value from drop duwn list, implemented as you recommend, inner exception occures: catched at Syncfusion.Windows.Forms.Grid.GridComboBoxCellRenderer.set_ControlText(String value) in :line 0 Is there a way to avoid the exception ? Thank you.


AD Administrator Syncfusion Team August 19, 2004 04:47 AM UTC

You will have to track down what is causing the exception. If you can post a complete call stack, we might be able to suggest something. Event better is if you can post a sample that we can use to reproduce teh problem. The kinds of things you need to look for might include conversion problems like you column requireing an integer and for some reason it is getting a string value that does not parse to an integer. Another problem that might appear is that the column itself has to have a datasource set for its combobox setting. If you have set DropDownStyle for the column to be exclusive, this means you can only have values in the cell that are actually in the DataSource for the whole column. So, you would have to have the column DataSource include all possibilities or change this setting.

Loader.
Up arrow icon