DataGrid showing instead of blank character null
Hello to everyone,
I have the following problem.
I have one DataAdapter which executes a command in a MS access database.The DataAdapter is used to fill a dataset and this dataset is datasource of a datagrid.
The problem is that in the cases that a cell is blank ,in the datagrid it appears to be null.I want to change this either programmaticaly or by design.
A solution could be to navigate through the dataset and foreach cell containing null to set it blank or any other String ,but i do not know how to do it.
Any help would be valuable.Thank you all
[575 byte] By [
mak_kats] at [2007-11-19 16:02:08]

# 1 Re: DataGrid showing instead of blank character null
If you use DataGridColumnStyles, you will be able to set the property NullText to an empty string.
Here is my article about the use of DataGridColumnStyles:
How To Use DataGridColumnStyles Programatically ( http://j1hammer.blogspot.com/2005/10/how-to-use-datagridcolumnstyles.html)
# 2 Re: DataGrid showing instead of blank character null
Thank you very much for your response.My code is the following
OleDbDataAdapter* da11;
da11 = new OleDbDataAdapter(viewc,con);
da11->Fill(s1,"main1");
dataGrid1->DataSource=s1->Tables->get_Item("main1");
Where viewc ,the string of the command
s1 , the dataset
dataGrid1, the datagrid
Well as i can see you use DataTable and DataColumn ,where i put them in the dataGrid with the fill method instantly.
Should i define two new variables :
DataGridTableStyle* smthing;
DataGridColumnStyle* smthing else ;
and map them the tablestyle to "main1" and columnstyle to every single column i have,by its name/header?
Thank you very much!
# 3 Re: DataGrid showing instead of blank character null
You should create a TableStyle, and set the MAppingName as the name of the table.
You should define a ColumnStyle for each and every Column you want to show in the grid, and set the MappingName of each column style to the name of the column in the table.
Just follow the example in the link I have posted.
After you set it up, you can play with the properties of ColumnStyles, such as Width, HeaderText and NullText