listbox with databind, but need to clear it on occasion

G

Guest

I have a list box that I am populating with a dataset.
It looks like
********
* Ted *
* Sam *
* Lori *
These values come from a table, used a stored procedure to fill a dataset.
I wanted to have a default text display like select..or even just blank to come up in the page load event. I tried using a select index of -1 but it just displayed the first index value from the dataset. An index of -2 creates a runetime error. I did not want to add a select.. string into the table that gets loaded in. I also have a clear button on the page and need to clear the listbox selection here as well.
Thanks Paul.
 
G

Greg Burns

With ddlRoutes
.DataSource = travelDB.GetRoutes
.DataTextField = "RouteName"
.DataValueField = "RouteID"
.DataBind()

.Items.Insert(0, New ListItem("-select route-", ""))
End With

HTH,
Greg

Paul said:
I have a list box that I am populating with a dataset.
It looks like
********
* Ted *
* Sam *
* Lori *
These values come from a table, used a stored procedure to fill a dataset.
I wanted to have a default text display like select..or even just blank to
come up in the page load event. I tried using a select index of -1 but it
just displayed the first index value from the dataset. An index of -2
creates a runetime error. I did not want to add a select.. string into the
table that gets loaded in. I also have a clear button on the page and need
to clear the listbox selection here as well.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top