DBNull.Value and the dropdownlist

Discussion in 'ASP .Net Web Controls' started by Filip De Backer, Apr 15, 2005.

  1. Hi everyone,

    I have created a new record in a datatable, and there is an integer field
    which has the value DBNull.Value, because at the moment of creation, the
    application doens't know which value to use.
    Then I want to bind a dropdownlist to this field of the datarow, but the
    dropdownlist gives an error because it has the DBNull.Value value.
    When the value of that field is set to 5 the binding is done without any
    error.

    The dropdownlist contains the values to store in the integer field, so the
    user of the web application must choose from that drowpdownlist. There is no
    default value, so I used DBNull

    Is there any sollution for this problem?

    thanks in advance,

    Filip
    Filip De Backer, Apr 15, 2005
    #1
    1. Advertising

  2. Filip De Backer

    Brock Allen Guest

    I'd create a second column that has an Expression property of: "IIF(Col1
    is NULL, 0, Col1)" and then DataBind to the second column.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Hi everyone,
    >
    > I have created a new record in a datatable, and there is an integer
    > field
    > which has the value DBNull.Value, because at the moment of creation,
    > the
    > application doens't know which value to use.
    > Then I want to bind a dropdownlist to this field of the datarow, but
    > the
    > dropdownlist gives an error because it has the DBNull.Value value.
    > When the value of that field is set to 5 the binding is done without
    > any
    > error.
    > The dropdownlist contains the values to store in the integer field, so
    > the user of the web application must choose from that drowpdownlist.
    > There is no default value, so I used DBNull
    >
    > Is there any sollution for this problem?
    >
    > thanks in advance,
    >
    > Filip
    >
    Brock Allen, Apr 15, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Boris Zakharin

    Adding a DBNull value to the database

    Boris Zakharin, Aug 27, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    375
    Boris Zakharin
    Aug 27, 2003
  2. Guest
    Replies:
    7
    Views:
    9,547
    Scott M.
    Jun 9, 2004
  3. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    DBNull.Value Question

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Nov 4, 2004, in forum: ASP .Net
    Replies:
    11
    Views:
    12,797
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=
    Nov 4, 2004
  4. darrel

    parameterized sql...dbnull value?

    darrel, Jul 3, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    5,493
    prasanth100
    Sep 5, 2010
  5. darrel
    Replies:
    1
    Views:
    447
    Karl Seguin
    Dec 12, 2006
Loading...

Share This Page