I'm working on a formsapplication with a datagrid in it. How can I disable or replace (null)-values in cells when im databinding the grid to a database. When I am in the Designer view and clicking on the little arrow on the grid,I only see the option "Autoformat"
A:
It seems to be that doing a simple boolean check on an object at query time would allow for you to filter nulls. Or in the actual query: not null
Woot4Moo
2009-12-13 23:21:58
No I dont want to eliminate records with null values in some columns, I just want to display it properly in my datagrid. By replacing (null) into "" for example
Janis
2009-12-13 23:26:28
well than the other suggestion would be to see if the object that you query back == null or object.myField == null.
Woot4Moo
2009-12-13 23:33:05
+1
A:
You could:
- To alter your database query to return your null columns with properly values
- To alter your grid to test if your value is null and deal with it
- To implement
DataGrid.ItemDataBound
event and treat your null values there
Depending on your framework version, you could to use null coalescing operator, ??
like:
string test1 = "123" ?? "no value"; // will have "123";
string test2 = null ?? "no value"; // will have "no value";
Rubens Farias
2009-12-13 23:32:39
A:
Ok, Another question, what grid is the best choise for a windows forms application ? I need to select 1 row at the time and need to edit or delete the row
Janis
2009-12-13 23:43:59
janis, SO doesnt work like this; I you have a useful answer, make it as answer, and post another question or you'll not have more answers
Rubens Farias
2009-12-14 00:29:25