Ask a Question related to ASP.NET General, Design and Development.
-
Northern #1
clear the display box of dropdownList in code
I need to write code clear the display box of my
DropDownList (something like clear current selected item)
while still keep the loaded item list in the DropDownList.
I tried DropDownList's ClearSelecttion() method and set
SelectedIndex to -1 but neither works.
How should I do this?
Thanks
Northern Guest
-
Unable to display the data in dropdownlist in datagrid
Hi all, I am unable to display the data in dropdown list in datagrid control. can anybody help me please? my ItemDataBound code is here..... ... -
Where Do I Place Date Code for Webpage Display
Hi, i have had no problem displaying the current date and time, on a static webpage. However, when i try to use the various PHP and MySQL snippets,... -
Clear screen
Hi, I'm using PHP on my Linux box on the command line. It need to clear the screen, as I would do with the 'clear' command on the bash. Is... -
how to display variables within using echo command within html code
this is part of my code question? why the variable $name and $address does not display on the html page instead of real values I do get... -
[PHP] Display HTML/PHP code on a web page
--- Jason Paschal <j_paschal@hotmail.com> wrote: Try htmlentities() Chris ===== Become a better Web developer with the HTTP Developer's... -
Ken Cox [Microsoft MVP] #2
Re: clear the display box of dropdownList in code
Is it that you just want to return to the default setting?
DropDownList1.SelectedIndex = 0
Or remove the one that is selected and leave the rest?
DropDownList1.Items.RemoveAt(DropDownList1.Selecte dIndex)
Ken
MVP [ASP.NET]
"Northern" <lifeng26@msn.com> wrote in message
news:002f01c34e23$748ceb00$a601280a@phx.gbl...
I need to write code clear the display box of my
DropDownList (something like clear current selected item)
while still keep the loaded item list in the DropDownList.
I tried DropDownList's ClearSelecttion() method and set
SelectedIndex to -1 but neither works.
How should I do this?
Thanks
Ken Cox [Microsoft MVP] Guest
-
Northern #3
Re: clear the display box of dropdownList in code
I guess I didn't phrase my question clearly.
I don't want to remove anything from the list's item
collection. What I want is just to clear the current
selection so that the display box of the dropdownbox on
the form will be blank. But if now I click on the dropdown
again, I can see all items are still there.
Thanks>-----Original Message-----
>Is it that you just want to return to the default setting?
>
> DropDownList1.SelectedIndex = 0
>
>Or remove the one that is selected and leave the rest?
>
>DropDownList1.Items.RemoveAt(DropDownList1.Select edIndex)
>
>Ken
>MVP [ASP.NET]
>
>"Northern" <lifeng26@msn.com> wrote in message
>news:002f01c34e23$748ceb00$a601280a@phx.gbl...
>I need to write code clear the display box of my
>DropDownList (something like clear current selected item)
>while still keep the loaded item list in the DropDownList.
>
>I tried DropDownList's ClearSelecttion() method and set
>SelectedIndex to -1 but neither works.
>
>How should I do this?
>
>Thanks
>
>
>.
>Northern Guest
-
Ken Cox [Microsoft MVP] #4
Re: clear the display box of dropdownList in code
I think the dropdownlist defaults to the first item in the order.
If you want nothing to appear, you would have to have a "blank" item as the
first item in the list. You could either add this when you build the
dropdownlist or later when you wanted to reset the appearance:
Private Sub Button2_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button2.Click
If DropDownList1.Items.IndexOf(DropDownList1.Items.Fi ndByValue("")) = -1
Then
DropDownList1.Items.Insert(0, "")
End If
DropDownList1.SelectedIndex = 0
End Sub
Ken
MVP [ASP.NET]
"Northern" <lifeng26@msn.com> wrote in message
news:03bb01c34e27$4a275a90$a001280a@phx.gbl...
I guess I didn't phrase my question clearly.
I don't want to remove anything from the list's item
collection. What I want is just to clear the current
selection so that the display box of the dropdownbox on
the form will be blank. But if now I click on the dropdown
again, I can see all items are still there.
Thanks>-----Original Message-----
>Is it that you just want to return to the default setting?
>
> DropDownList1.SelectedIndex = 0
>
>Or remove the one that is selected and leave the rest?
>
>DropDownList1.Items.RemoveAt(DropDownList1.Select edIndex)
>
>Ken
>MVP [ASP.NET]
>
>"Northern" <lifeng26@msn.com> wrote in message
>news:002f01c34e23$748ceb00$a601280a@phx.gbl...
>I need to write code clear the display box of my
>DropDownList (something like clear current selected item)
>while still keep the loaded item list in the DropDownList.
>
>I tried DropDownList's ClearSelecttion() method and set
>SelectedIndex to -1 but neither works.
>
>How should I do this?
>
>Thanks
>
>
>.
>
Ken Cox [Microsoft MVP] Guest



Reply With Quote

