clearing dropdownlist selected value

I have this problem when I try to assign selected value using codebehind, even though I already put the code:

dropdownlist.selectedindex=null
or dropdownlist.selectedindex=-1
or dropdownlist.selectedindex=""

all throw error said it can’t have duplicate selected value.
now there are two way to clear the selected value, first by do it twice, like what is listed in bug section in Q327244 (http://support.microsoft.com/default.aspx?scid=kb;en-us;327244), like this:

dropdownlist.selectedvalue=-1 ‘this will change the selected value index to index number 0
dropdownlist.selectedvalue=-1 ‘this will clear all selected item

or add this code:

dropdownlist.ClearSelection()

Advertisements

Null changed to Nothing in Visual Studio 2008

in many example i found in the internet it seems doesn’t work in my VS 2008, they code always has blue line under the Null word.

on the pop up they said:

‘Null’ is not declared, ‘Null’ constant is no longer supported; use system.DBNull instead

Continue reading