This is a migrated thread and some comments may be shown as answers.

How to handle null value

3 Answers 445 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ramius
Top achievements
Rank 1
Ramius asked on 21 Dec 2009, 03:18 PM
How to handle null value with the GridViewCheckBoxColumn, GridViewMaskBoxColumn, GridViewDateTimeColumn, GridViewDecimalColumn, GridViewImageColumn, GridViewTextColumn, GridViewComboBoxColumn ?

Is there any documentation available ?

Kind Regards,

Ramius

3 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 22 Dec 2009, 09:54 AM
Hi Ramius,

Thank you for your question. You may read more about the type of columns here. What do you actually want to manage in case of a 'NULL' value? Let me know, if you need additional help.

Sincerely yours,
Svett
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ramius
Top achievements
Rank 1
answered on 22 Dec 2009, 11:46 AM
Hi Svett,

thank you for the link to the documentation but there is no information on how to set a null value to a column.
In my scenario i have a special null value for a datetime column ( 31.12.9998 ).

How can i tell the GridViewDateTimeColumn that this is my null value ?

Kind Regards,

Ramius
0
Svett
Telerik team
answered on 23 Dec 2009, 02:44 PM
Hello Ramius,

You cannot set a null value for a specified column. You may subscribe to CellFormatting event and change the text of the cell in case of your value.  You may read more about it here.

In your case, it must be something like that:

private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    GridViewDataColumn dataColumn = e.CellElement.ColumnInfo as GridViewDataColumn;
 
    if (dataColumn.UniqueName == "HireDate")
    {
        DateTime dtValue = (DateTime)e.CellElement.RowInfo.Cells[dataColumn.UniqueName].Value;
 
        if (dtValue == new DateTime(9998, 31, 12))
        {
            e.CellElement.Text = "MY DEFAULT TEXT IN CASE OF MY NULL VALUE";
        }
    }
}

Let me know, if you need further assistance.

Best wishes,
Svett
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Ramius
Top achievements
Rank 1
Answers by
Svett
Telerik team
Ramius
Top achievements
Rank 1
Share this question
or