Hi
I have a grid and when i select a row from it if it has null values it should also be displayed. How can i do this???
Printable View
Hi
I have a grid and when i select a row from it if it has null values it should also be displayed. How can i do this???
What type of grid? There ae several in the .NET Framework, not to mention numerous third-party grids too. Please make your questions as specific as possible.
its a data grid...i use it to show details from the database......i get an error whn few of the fields in the database r empty.....but i want to display those empty fields also......
So it's a System.Windows.Forms.DataGrid, definitely not a DataGridView?
I have a little question here. What is the difference between DataGrid and DataGridView? On MSDN gives a quite smiler explanation.
The DataGridView was written from the ground up and added to the Framework in version 2.0 as a replacement for the DataGrid. It is much more functional and easier to extend.Quote:
Originally Posted by eranga262154
You mean a whole database?
Its a data grid view......so wht do i do to display th null values also??? mostly i will b retriving only one value at a time..but thr may b cases whr i need to get different values also.......To be more specific i'll be displaying only one row from the database....but thr may be cases whr i need to show multiple rows.....so wht do i do??
It's very importatnt that you use the proper names for things. The DataGridView behaves quite differently to the DataGrid, which is why I was so careful to qualify. Advice given for one is likley to be useless for the other.
You need to set the DefaultCellStyle.NullValue property of the column. For instance, if you wanted to display "{null}" in cells with null values in the second column you would do this:If you're creating your columns in the designer then you should also set the NullValue in the designer rather than in code.vb.net Code:
Me.DataGridView1.Columns(1).DefaultCellStyle.NullValue = "{null}"
Look that pretty easy to me. But what happened if there is large number of columns.
We're talking columns, not rows. You set that property for the column and then every cell in that column will display that value for nulls, even if there are millions of rows.Quote:
Originally Posted by eranga262154
Thank guys......But i needed th code to b in c#......and abt the names i'll be more carefull from now on......
Code:this.DataGridView1.Columns[1].DefaultCellStyle.NullValue = "{null}";
Thank you very much buddy......:thumb: