is this what you want?? it will clear all items listed in the
dropdown..
dd_CodeCode.Items.Clear()

or  this

first you have to add an Initial Blank item on your Dropdown

ListItem BlankItem= new ListItem("", "0");


dd_CodeCode.SelectedValue=0;



On Nov 5, 4:45 am, Imstac <[EMAIL PROTECTED]> wrote:
> On my web form I have a textbox control (jobno) and a dropdown list
> (DD_costcode).  The values that are populated into the dropdown list
> are based on what is keyed into the textbox.  When I key a value into
> my textbox the values populate in my dropdown list and the first value
> in the dropdown list appears.  This works great.  What I can't get to
> work is if a user goes back to the textbox control and deletes the
> value in there I need the dropdown list to clear out the previous
> values and just be blank.
>
> I've tried using an textchanged event handler on my textbox control
> and set the dropdown list value to nothing when the textbox value is
> empty but that didn't work and then I tried setting the dropdown value
> to "" but that gives me an error that the dropdown list selected value
> is invalid because it is not in the list.
>
> Does anyone know how I can set the value to blank in my dropdown
> list?
>
> Here is my event handler code (DD_costcode is my dropdown list).
>
> Protected Sub Jobno_TextChanged(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles jobno.TextChanged
>         If jobno.Text = Nothing Then
>
>             GLAcct.Enabled = True
>             GLAcct.BackColor = Drawing.Color.White
>             DD_CostCode.SelectedValue = Nothing
>
>         Else
>
>             GLAcct.BackColor = Drawing.Color.Gray
>             GLAcct.Enabled = False
>
>         End If
>
>    End Sub

Reply via email to