Catering for DBNull.Value items.

2 posts, 0 answers
  1. Ian Coetzer
    Ian Coetzer avatar
    65 posts
    Member since:
    Sep 2004

    Posted 17 Nov 2008 Link to this post


    How can I set values (bind) to the RadNumericInput control:
    (as shown below)

    Value='<%# DataBinder.Eval(Container, "DataItem.Salary")%>'    

    But cater for DbNull.Value values?
    The users do not want to see the value zero "0.0000" they want to be able to see that the value is null, nothing / blank textbox.
    I receive a "Specified cast is not valid." error message if I try and bind it to a datatable with some Null values.

    Here is my full RadNumericTextBox control declaration:

                            <telerik:RadNumericTextBox ID="radNumericTextBox" runat="server" Type="Number" 
                                Value='<%# DataBinder.Eval(Container, "DataItem.Salary")%>'                           
                                LabelCssClass="radLabelCss_Web20" Skin="Telerik" Width="80px" style="TEXT-ALIGN: left"   
                                Font-Size="8pt" > 
                                <NumberFormat DecimalDigits="4" /> 
                                <FocusedStyle BorderColor="Red" BorderStyle="Double" /> 
                                <HoveredStyle BorderColor="Red" BorderStyle="Double" /> 
  2. Plamen Peshev
    Plamen Peshev avatar
    885 posts

    Posted 17 Nov 2008 Link to this post

    Hello Ian,

    To see more information on the requested functionality, please refer to the following article:

    All the best,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top