473,378 Members | 1,280 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

listbox with databind, but need to clear it on occasion

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.
--
Paul G
Software engineer.
Nov 18 '05 #1
1 1179
With ddlRoutes
.DataSource = travelDB.GetRoutes
.DataTextField = "RouteName"
.DataValueField = "RouteID"
.DataBind()

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

HTH,
Greg

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:72**********************************@microsof t.com...
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.
--
Paul G
Software engineer.

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fieldmedic | last post by:
I'm attempting to get an arraylist to display in a Listbox (listbox2). The arraylist is created from selections in a different listbox (listbox1). The 1st listbox has a selection mode of...
2
by: mathieu cupryk | last post by:
I have problems with listboxes in the webform2.cs, the textboxes are working well when I do a click on next. I am missing something. It works with the textboxes. Here is the file: using System;...
2
by: Gordon | last post by:
Hi; I am a novice asp.net developer who would like to create a dataset-table and then use the datatable.select cmd. to look up a value passed from the web calender control. The value(s) would...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
1
by: yamne | last post by:
I have a problem. When I click in edit datagrid button I show two listbox and two button. I use two button to move data between two listbox. My problem is that I can't call the listbox in the...
3
by: Joey | last post by:
Hi, I'm trying to add a default item to my listbox but when I do it tells me that it's not defined, could someone tell me the syntax I need to use to get the listbox control to display a default...
4
by: dtblankenship | last post by:
Hello everyone, I know this question has been asked many times in the forums, and after spending a few days reading, I am still confused as to the answer. I have a ListBox (lstBox),...
4
by: Seok Bee | last post by:
Dear Experts, I am having 1 listbox control in my web form and trying to retrieve the items and load into it. I want to list out those uploaded files into the database and list out in the...
2
by: rrflore2 | last post by:
Ok. I'm writing and deleting to an xml file using a dataset. I have a function in my codebehind page that binds a listbox to the dataset that performs the writes/deletes. Everything seems to be...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.