Hi,
I have the ultrawingrid which is showing default value :- '01\01\1990' in case of null value in database.
Could any one suggest for how to display blank value for the above case.
Thanks in advance,
Perhaps have the InitalizeRow event look for '01\01\1990' and set that cell 100% transparent? That's what I do on my Ticket List, except I use 1/1/2100.
Well, if you just want to hide the cell, you could set the Hidden property on the cell instead of setting it to Transparent. But that means the user cannot edit the cell. So that's find if the cell is not editable, anyway.
If your database contains a null date and you are loading that data into a DataSource that can bind to the grid, such as a DataTable, then the DataTable is perfectly capable of holding a value of BDNull.Value for that field. In which case, the grid will show a blank cell.
So one way to handle this would be to modify the local data, changing 1/1/0001 to DBNull.Value when reading from the database and vice versa when saving. If your local data source contains 1/1/0001, instead, and you want that to show as a blank, the best way to handle this would be to hide the "real" column and then show an unbound column in it's place and do the translation there. I have attached a small sample project here demonstrating this approach.
3022.MemDataTable CS.zip
I know this post is 9 years old, but i've seen a few different posts asking the same question. Mike, you are not really helping these people. They are asking that if you have a datasource where the date has not been set yet, hence the 1/1/0001 value, how do they display it on the grid as blank instead of the min value. You have not provided any helpful answer.
What you are doing here is changing the Value of the cell. So this will update the DataSource, as well. If that's what you want, then why is your data source returning a date in the first place?
Hello,
Thanks for reply.
I have tried the following :
private void salesGrid_InitializeRow(object sender, InitializeRowEventArgs e) { if (e.Row.Cells["Promise Date"].Value != DBNull.Value) { DateTime l_dtInvDate = Convert.ToDateTime(e.Row.Cells["Promise Date"].Value); DateTime l_dtDefautDate = Convert.ToDateTime("1/1/1900 12:00:00 AM"); if (l_dtInvDate == l_dtDefautDate) { e.Row.Cells["Promise Date"].Value = DBNull.Value; } }}
And its working fine now for me.
Will it work properly without any bug in future?