Handle NULL in datagrid

eramgarden

Contributor
Joined
Mar 8, 2004
Messages
579
I have a datagrid that displays NULL when the field in the database is NULL. I want it to display blank.

I have searched Google for examples and whatever I've found talks about:

DataGridColumnStyle,TableStyle..etc.

The DataGridColumnStyle class allows you to change the "(null)" text. You
will have add a TableStyle to your datagrid, and add ColumnStyles to the
TableStyle. Look at the TableStyles property of the datagrid.


OR

Add a DataGridTableStyle to your grid. Then in the DataGridColumnStyle for
the column in question, set its NilLText property to whatever you want.


OR
One way to do this is by Using DataGrid Table Styles Collection . After
Setting Datasource and DataMember of Grid , Click on the TableStyles
Collection editor of DataGrid Add a new TableStyle and Set the Mapping name
to your TableName . Click on the GridColumnStlyes Collection Editor and Add
DataGridTextBoxColumns to Column Style Collection Editor. . Each
DataGridTextBoxCOlumn has a Property called Nul text , You can remove the
null there so that it will be shown as Empty .


But WHERE is this info..tablestyle, datagridtextboxcolumns...etc they're talking about. I cant add it thru HTML or code behind or GUI of my datagrid...

Going nuts..
 
is changing the SQL an option??

Instead of
SELECT Column FROM Table
say:
SELECT IsNull(Column,' ') As Column FROM Table

then you don't have to worry about the difference between NULL and Empty String
 
Back
Top