|
-
Jul 22nd, 2007, 11:48 PM
#1
Thread Starter
Junior Member
Displaying Null values from database
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???
-
Jul 23rd, 2007, 12:53 AM
#2
Re: Displaying Null values from database
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.
-
Jul 23rd, 2007, 11:39 PM
#3
Thread Starter
Junior Member
Re: Displaying Null values from database
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......
-
Jul 24th, 2007, 12:14 AM
#4
Re: Displaying Null values from database
So it's a System.Windows.Forms.DataGrid, definitely not a DataGridView?
-
Jul 24th, 2007, 12:20 AM
#5
PowerPoster
Re: Displaying Null values from database
I have a little question here. What is the difference between DataGrid and DataGridView? On MSDN gives a quite smiler explanation.
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Jul 24th, 2007, 01:01 AM
#6
Re: Displaying Null values from database
 Originally Posted by eranga262154
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.
-
Jul 24th, 2007, 01:05 AM
#7
PowerPoster
Re: Displaying Null values from database
You mean a whole database?
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Jul 24th, 2007, 09:30 PM
#8
Thread Starter
Junior Member
Re: Displaying Null values from 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??
Last edited by arunhere; Jul 24th, 2007 at 09:42 PM.
Reason: To be more specific
-
Jul 24th, 2007, 11:51 PM
#9
Re: Displaying Null values from database
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:
vb.net Code:
Me.DataGridView1.Columns(1).DefaultCellStyle.NullValue = "{null}"
If you're creating your columns in the designer then you should also set the NullValue in the designer rather than in code.
-
Jul 25th, 2007, 01:03 AM
#10
PowerPoster
Re: Displaying Null values from database
Look that pretty easy to me. But what happened if there is large number of columns.
Last edited by eranga262154; Jul 25th, 2007 at 01:05 AM.
Reason: Incomplete
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Jul 25th, 2007, 01:34 AM
#11
Re: Displaying Null values from database
 Originally Posted by eranga262154
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.
-
Jul 25th, 2007, 09:56 PM
#12
Thread Starter
Junior Member
Re: Displaying Null values from database
Thank guys......But i needed th code to b in c#......and abt the names i'll be more carefull from now on......
-
Jul 25th, 2007, 10:15 PM
#13
Re: Displaying Null values from database
Code:
this.DataGridView1.Columns[1].DefaultCellStyle.NullValue = "{null}";
-
Jul 30th, 2007, 09:29 PM
#14
Thread Starter
Junior Member
Re: Displaying Null values from database
Thank you very much buddy......
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|