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

Databound grid access

Hi, I am using a databound grid. In grid i have some columns of type ComboBox and corresponding data column is of type bool. Now some time when i try to get the state of combo box using the data table it gives me error ''specfied cast not valid'' if((bool)m_AlarmDetailsTable.Rows[Index] [DisplayGuageColIndex]) strDisplayGuage = "1"; Please go through attached code for details. -Rajiv

5 Replies

AD Administrator Syncfusion Team March 27, 2004 05:09 PM UTC

Is the value Nothing (or DBNull.Value)? If so, this will give you an invalid cast. It appears you are directly checking the values in the DataTable. Can you post a sample project showing the problem?

RA Rajiv March 29, 2004 05:00 AM UTC

Please find attached code. I am checking on bool value which is set to false by default. This problem is not very regular. -Rajiv >Is the value Nothing (or DBNull.Value)? If so, this will give you an invalid cast. > >It appears you are directly checking the values in the DataTable. > >Can you post a sample project showing the problem? AlarmUI_9703.zip

AD Administrator Syncfusion Team March 29, 2004 06:49 AM UTC

I cannot run your code because of missing references so I cannot debug into the problem to try to spot what is going on. Here is something to try. Instead of trying to set a default value with this code, gridAlarmDetails.Binder.InternalColumns[Index].StyleInfo.CellValue = false; try this code: gridAlarmDetails.Model.ColStyles[Index + 1].CellValue = false; The grid gets it default column values from the values in ColStyles. If this does not work, then try setting the DataColumn.DefaultValue for each of these columns in the DataTable. (Set these DefaultValues before you add any rows to the Datatable.)

RA Rajiv April 3, 2004 08:32 AM UTC

Hi, Even after setting the default values it is giving same error. I did some analysus and founf out that ''Specified cast not valid'' error comes when we try to access some cell after draging some cell over it. Now my problem is how to disable drag and drop for essential grid. I have the following code but it does not disable the draging. // Disable Drag Drop gridAlarmDetails.Model.Options.AllowDragSelectedCols = false; gridAlarmDetails.Model.Options.AllowDragSelectedRows = false; gridAlarmDetails.Model.Options.DragDropDropTargetFlags = 0; gridAlarmDetails.Model.Options.DragSelectedCellsMouseButtonsMask = System.Windows.Forms.MouseButtons.None; In my grid i have some static field, checkboxes etc. Please refer to attached file for more details. Regards, Rajiv AlarmsManagerUI_5838.zip

AD Administrator Syncfusion Team April 3, 2004 08:51 AM UTC

The code you show controls whether you can move rows/column by first selecting them, and then mousing down on the selected row/columns to move them to a new position. If you want to turn off ole drag and drop support in the grid, you use code like: this.gridControl1.ControllerOptions = GridControllerOptions.All & (~GridControllerOptions.OleDataSource);

Live Chat Icon For mobile
Up arrow icon