Hi everyone,
anyone knows how to set the value of a UltraWinGrid cell to null (Nothing in VB.NET). I've tried this code but it does'nt work
For Each gridCell As Infragistics.Win.UltraWinGrid.UltraGridCell In gridCells
gridCell.Value = Nothing
Next
If the cell already contains the null value I don't receive any error message and everything works fine. But, if the cell contains a value (in that case an integer) I cannot set back the value to nothing and I receive this error message : Unable to convert from (null) to 'System.Nullable'1[System.Int32]
Anyone konws how to do such things???
Hello Nipun,
Why are you using this code? You can just use the 'ToString()' method, like this:
ultraGrid1.Rows[0].Cells[0].Value.ToString();
I might have misunderstood you, please let me know if that is the case.
Hi Mike,
I have started using infragistics very recently because of my new project requirements. I am stuck at a place where the requirement is to change the UltraGridCell.Value to string type. Here the UltragridCell originally could be of any type like int,dataetime. Now I am not finding a way where I can replace the cell value which is of type Int64 to string. Please help. The code below may give you some idea what I am trying to do
TypeCode cellType = Type.GetTypeCode(row.Cells[maskedColumn.Key].Value.GetType());
row.Cells[maskedColumn.Key].Value = Convert.ChangeType(maskedColumn.Value, cellType);
Here as expected the exception I am getting is "Input string was not in correct format". How can I resolve this?
Thanks,
Nipun
Great. :)
If you still want to get the hot fix, you can find it here: My Infragistics Keys and Downloads - Download Anything and Everything You Own
Good news, I've foud the solution.
I've forgot to set the "Nullable" property of the column at the grid layout initialization.
I've added this line of code at the grid layout initialization and everything works fine :
"e.Layout.Bands(0).Columns("colunmName").Nullable = Nullable.Nothing"
With that line of code, the grid know how to handle the null value for the column.
Thanks for your help!! :-)
1 -We use version 6.2.20062.34. Of the NetAdvantage for .Net 2006.2 CLR 2.0
Where can I find the hotfix you've talked about?
2 - I use a generic list (List(Of "my object with nullable property")
3 - I've tried to use DBNull.value but it does not works.
To be clearer, I've bond a grid with a list of a certain object type containing some nullable fields. When binding, the grid works properly. I've also placed in some cells of the grid Ultra dropdown to display data in a way much more user friendly.
After the binding of the grid I try to remove the value contained in a cell (the object property binded to this cell is set to a nullable type (Nullable(Of Integer)) but each time I try to do that I receive the following error message : "Unable to convert from (null) to 'System.Nullable'1[System.Int32]".
I think it's because the null value of the cell is not equivalent to the .NET 'System.Nullable' type.
Maybe it's because the cell does'nt know the type of the object property is binded to? Could I Set the datatype of the cell content?
What do you think?