I''m using GDBG grid.In that i''m binding an Arraylist as Datasource for drop-down cell types in a column. After selecting a value from Drop-down, when i''m leaving out of the current cell, the custom validation is getting fired and its not allowing me to come out of the cell.
The Array list has got the same data as that of the column.
Here, If u can tell me the way for how to disable the custom validation, it would of great help.
ADAdministrator Syncfusion Team September 17, 2004 04:52 AM
Exactly what message are you getting?
You need to make sure that the type of the ValueMember in your ArrayList is the same as the type of the column in the DataSource of the grid. For example, if the grid''s DataSource holds an int in that column, the ValueMember property of the ArrayList should also be an int.
THThiyaguSeptember 17, 2004 05:01 AM
I''m getting "Component must be Myobject Type". Here I dont want the validation to happen. Because, I''m binding an arraylist which has got a combination of Id(int) and name(string) and the column is holding only the string.
The scenario is the user will get the drop-down only if he clicks on Add/Edit. By that time only I''m changing the cell type to be of combo box. So, Is there any way so that I can disable the validation of cell??..
>Exactly what message are you getting?
>You need to make sure that the type of the ValueMember in your ArrayList is the same as the type of the column in the DataSource of the grid. For example, if the grid''s DataSource holds an int in that column, the ValueMember property of the ArrayList should also be an int.
ADAdministrator Syncfusion Team September 17, 2004 05:16 AM
>>Is there any way so that I can disable the validation of cell??..
The problem is if your grid''s DataSource holds a string, then the grid must have a string to assign to it. If your valuemember on the combobox is a int, then grid does not have the string to assign. And this is the problem. The validation only displays the problem. Avoiding the validation will not avoid the problem of the grid not having the proper type to assign as the grid uses the ValueMember to decide what to put into its data source. And if these two types do not match, then the grid cannot properly set the value into the datasource.
So, if your grid column holds a string, and you want to have the string from the combobox set into the grid, then you might try making the displaymember and valuemember both be the string. The int value would play no role in this case.
If you want to avoid the validation, you can derive the grid and override OnCurrentCellValidating, and there, do not call the baseclass. But this will not resolve the problem of the grid trying to put an int value into a string column in a datatable.
THThiyaguSeptember 17, 2004 05:48 AM
I''m not going to save the int value in the database. I''m using the int value just for reference(While updating, I''m using this int value in the where clause). Again, I''ve tried with the arraylist which holds string alone but that also not working.
ADAdministrator Syncfusion Team September 17, 2004 06:24 AM
>>I''''m not going to save the int value in the database.
What do you want to save in the database? Nothing?
If nothing, then try handling grid.Model.SaveCellInfo. In your handler, if e.ColIndex and e.RowIndex point to one of these cells, then set e.Handled = true. This should prevent anything from being saved.
If you want to save something in particular, then in SaveCellInfo, try explicitly setting e.Style.CellValue to be what you want to save when when e.ColIndex and e.RowIndex point to one of these cells, and do not set e.Handled = true.
If you can post a sample project showing the problem, we can try to find a solution.
THThiyaguSeptember 17, 2004 07:00 AM
Thanks a lot Clay. This is what I''m exactly looking for.
Thanks a lot.