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

GridDataBoundGrid Exception being caught

Thanks! Gonna try that out, but am still wondering why the exception was being caught. I have noticed that when there is an exception caught 9 times out of 10 its something negligent on my part. ------------------------------------------------- By Trevor at 4/7/2005 6:00:46 PM Greetings, In my grid I am having a problem with it catched a particular recurring exception. The error message is: catched at Syncfusion.Windows.Forms.Grid.GridComboBoxListBoxHelper.FindKey(IList thisList, PropertyDescriptor property, Object key) in :line 0 It recurs about 25-30 times and I am not sure where I should throw in the try catch to try to find it. I cant seem to find any documentation on it. Any help would be appreciated. There is a lot of code associated with this so thats why I am not posting it up. Thanks. By Trevor at 4/7/2005 7:14:41 PM Greetings, I would like to further describe the error. The error occurs mostly when I hover over a ComboBox that is dynamically loaded in the QueryCellInfo event of the gridModel. The code references a preloaded dataset for data and then sets the combo box''''s data source accordingly. I am suspicious about the GridStyleINfo and wonder if its being invalidated somehow and recrated causing some kind of problem finding the reference to the datatable. I can provide code if needed. The things I have tried are checking to see if the DataSource is null before setting the source to the table (since the query cell info seems to fire rather often). I have played around with the Binder/Model/Grids Begin/End Update/Init and the grid''''s refresh to no avail. I am not certain how to properly use them as its difficult to understand when to use which one (I understand the Binder should only be used when changing the underlying datasource which I am not doing so I dont use that one and I know placing the refresh in the QueryCellInfo throws it into an infinite loop). If needed I can setup a DirectTrack Incident for this. By Clay Burch at 4/8/2005 10:11:37 AM You might want to report this in the grid forum so it will be seen by our grid users who might have feedback for you. What version of our libraries are you using? Generally, it is better to dynamically set dropdownlist using the CurrentCellShowingDrop event. The reason is that this event is only raised when the user clicks the cell to indcate that he want to see the dropdown. QuertCellInfo is hit constantly, and you normally want to restrict the type of code you use in that event. Here is a forum thread that has a sample showing one way to dynamically set the dropdown. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=18524

11 Replies

AD Administrator Syncfusion Team April 8, 2005 02:59 PM UTC

If you can post a sample project showing the problem, we can probably expalin teh exception. Or, you an submit a direct trac support incident with a sample if that is better for you.


AD Administrator Syncfusion Team April 8, 2005 03:48 PM UTC

The code is so intertwined with our framework that it would be really difficult to send you a sample solution. The solution you suggested worked and the performance increase was dramatic however I am having another "catched" error by the grid. catched at Syncfusion.Windows.Forms.Grid.GridComboBoxCellRenderer.set_ControlText(String value) in :line 0 catched at Syncfusion.Windows.Forms.Grid.GridTextBoxControl.WndProc(Message& msg) in :line 0 Well two errors, the first one happens when I click the drop down, the second one happens when i simply by double clicking the cell with the drop down in it. The version we use is 2.1.0.9. Thanks.


AD Administrator Syncfusion Team April 8, 2005 03:57 PM UTC

The issue that I am currently having is that the ValueMember portion of the code doesnt seem to work right. The code that its set at follows: ---------------------------------------------- // Current Cell GridCurrentCell cc = this.dataGrid.CurrentCell; // Current Renderer GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer; // Ensure things are nice and tidy if ( cr != null ) { int appCellTypeID = GetApplicationSettingCellTypeID((int)gridModel[cc.RowIndex, sIndex].CellValue); // Exists if ( appCellTypeID != -1 ) { // DataSet DataTable table = new DataTable(); // Adapter SqlDataAdapter tempAdapter = new SqlDataAdapter(GetOptionValue(appCellTypeID, GetOptionByProperty("DataSource")) as string, connectionString); // Fill tempAdapter.Fill(table); // Set DataSource try { ((GridComboBoxListBoxPart)cr.ListBoxPart).ValueMember = GetOptionValue(appCellTypeID, GetOptionByProperty("ValueMember")) as string; ((GridComboBoxListBoxPart)cr.ListBoxPart).DisplayMember = GetOptionValue(appCellTypeID, GetOptionByProperty("DisplayMember")) as string; ((GridComboBoxListBoxPart)cr.ListBoxPart).DataSource = table; } catch ( Exception ex ) { Diagnostics.DebugExtensions.WriteException(ex); } } }


AD Administrator Syncfusion Team April 8, 2005 04:55 PM UTC

Can you set the ValueMember and DisplayeMember on the GridBoundColumn.StyleInfo object for that column? Do these vary or are they more or less fixed? If you can set them into this style oject before teh active cell control is initialized, I think things will initailzied properly and you will be able to dynamically det teh drop list (though the ValueMember and DisplayeMember are more or less static).


AD Administrator Syncfusion Team April 8, 2005 05:02 PM UTC

Ill give you an explanation of whats happening here. This is a Application Setting Control that has the grid on it. Each setting is displayed on the grid, but the cell containing the user inputed value is dependant on the settings stored in the database. So some columns will be CellBox''s, some will be Currencies, some month calendars.. you get the idea. So each cell is handled on its own. I tried setting the StyelInfo in the CurrentCellShowingDropDown event but to no avail. The only problem I have now is that the value member isnt working the way I had expected (strange since before I set the Display/Value Members, the drop down list only showed System.Data.DataRowViewItem * the number of rows that were being displayed.) Anyway I have officially run out of ideas to get this to work (maybe use a Hashtable or something to store the values and if its a combo box i phsically get the value from the DB, but that really begins to defeat the purpose of this grid...) Your help is most appreciated!


AD Administrator Syncfusion Team April 8, 2005 05:13 PM UTC

>>I tried setting the StyelInfo in the CurrentCellShowingDropDown event but to no avail. It is too late at that point. If you cannot set the GridBoundCOlumn.StyleInfo for that column, then I think you will have to use QueryCellInfo. In the handler, if it is this column, then set e.Style.DataMember and e.Style.ValueMember there. (but do not set the DataSource).


AD Administrator Syncfusion Team April 8, 2005 05:42 PM UTC

Thats what I thought I would do but the problem is that even though the Value/Display Members are correct, I only get System.Data.DataRowView displayed in the combobox... I thought it had something to do with the fact that the DataSource being set is the ListBoxPart datasource and not the GridStyleInfo datasource.


AD Administrator Syncfusion Team April 8, 2005 05:54 PM UTC

If you see DataRowView displayed, that suggests that teh mapping names for teh ValueMember and DisplayMember are not being resolved properly. Check the spelling, and these are case sensitive. Have you tried explicitly setting them in the GridBoundColumn.StyleInfo at teh same time you set the GridBoundColumn.StyleInfo.CellType = "ComboBox" to see if things work if you set them at that point?


AD Administrator Syncfusion Team April 8, 2005 06:02 PM UTC

Thanks for the suggestion. I tried that and sadly it didnt work. The odd thing is that if I uncomment the following lines: listBoxPart.DataSource = table; // listBoxPart.ValueMember = GetOptionValue(appCellTypeID, GetOptionByProperty("ValueMember")) as string; // listBoxPart.DisplayMember = GetOptionValue(appCellTypeID, GetOptionByProperty("DisplayMember")) as string; things start to work again (well the DisplayMember works correctly, the ValueMember just returns the DisplayMember). Since I am using the same GetOpionValue functions to get the data from the DB (and in my debugging sessions the first thing I confirmed was that the Style.Value/Display Members were being set properly). I tried setting the value/display member manually as you suggested as well but that didnt seem to work either, it showed Data.DataRowView again.


AD Administrator Syncfusion Team April 8, 2005 06:13 PM UTC

Maybe this will shed some light... If I uncomment just the ValueMember the ComboBox lists 1,2,3,4 (the ID''s , what I want from the ValueMember). If I uncomment both, I only get the DisplayMember.. maybe I am accessing the value incorrectly.. should I use .CellValue to access the Value?


AD Administrator Syncfusion Team April 8, 2005 06:16 PM UTC

After checking the code I found out that I am getting the Value using a columnExpression. There are 3 "Value" columns, UserValue, RoleValue and Value. UserValue is inpuited, RoleValue is inherited and Value is the actual value depending on whether you inherit or not. This is an expression Column that goes like this: -------------------------------------------- column.Expression = "IIF(InheritFromRole = 0, UserValue, RoleValue)"; -------------------------------------------- This is returning the display member instead of the value member... Thanks.

Loader.
Live Chat Icon For mobile
Up arrow icon