How to handle null value

4 posts, 0 answers
  1. Ramius
    Ramius avatar
    127 posts
    Member since:
    Feb 2008

    Posted 21 Dec 2009 Link to this post

    How to handle null value with the GridViewCheckBoxColumn, GridViewMaskBoxColumn, GridViewDateTimeColumn, GridViewDecimalColumn, GridViewImageColumn, GridViewTextColumn, GridViewComboBoxColumn ?

    Is there any documentation available ?

    Kind Regards,

    Ramius
  2. Svett
    Admin
    Svett avatar
    728 posts

    Posted 22 Dec 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ramius
    Ramius avatar
    127 posts
    Member since:
    Feb 2008

    Posted 22 Dec 2009 Link to this post

    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
  5. Svett
    Admin
    Svett avatar
    728 posts

    Posted 23 Dec 2009 Link to this post

    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.
Back to Top