473,413 Members | 2,043 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,413 software developers and data experts.

get first and last datavalue field entry of dropdown box

probably an easy way to do this but in the code behind I could not see how to
get the first and last data value field of a dropdown listbox. I have the
data value field being populated with a table ID and the data text field
being populated by a table field name. I also have an objectdatasource that
is bound to the dropdown box so there is probably a way to get the
information from the objdatasource as well.
Thanks Paul.
--
Paul G
Software engineer.
Jun 27 '08 #1
3 1655
On Jun 9, 8:27*pm, Paul <P...@discussions.microsoft.comwrote:
probably an easy way to do this but in the code behind I could not see howto
get the first and last data value field of a dropdown listbox. *I have the
data value field being populated with a table ID and the data text field
being populated by a table field name. *I also have an objectdatasource that
is bound to the dropdown box so there is probably a way to get the
information from the objdatasource as well.
Thanks Paul.
--
Paul G
Software engineer.
Hi Paul

I think, you can use Items collection

DropDownList1.Items[0].Value
DropDownList1.Items[DropDownList1.Items.Count].Value

Hope this helps

Jun 27 '08 #2
I think that is what I was looking for, thanks.
--
Paul G
Software engineer.
"Alexey Smirnov" wrote:
On Jun 9, 8:27 pm, Paul <P...@discussions.microsoft.comwrote:
probably an easy way to do this but in the code behind I could not see how to
get the first and last data value field of a dropdown listbox. I have the
data value field being populated with a table ID and the data text field
being populated by a table field name. I also have an objectdatasource that
is bound to the dropdown box so there is probably a way to get the
information from the objdatasource as well.
Thanks Paul.
--
Paul G
Software engineer.

Hi Paul

I think, you can use Items collection

DropDownList1.Items[0].Value
DropDownList1.Items[DropDownList1.Items.Count].Value

Hope this helps

Jun 27 '08 #3
On Jun 9, 10:16*pm, Paul <P...@discussions.microsoft.comwrote:
I think that is what I was looking for, thanks.
--
Paul G
Software engineer.

"Alexey Smirnov" wrote:
On Jun 9, 8:27 pm, Paul <P...@discussions.microsoft.comwrote:
probably an easy way to do this but in the code behind I could not seehow to
get the first and last data value field of a dropdown listbox. *I have the
data value field being populated with a table ID and the data text field
being populated by a table field name. *I also have an objectdatasource that
is bound to the dropdown box so there is probably a way to get the
information from the objdatasource as well.
Thanks Paul.
--
Paul G
Software engineer.
Hi Paul
I think, you can use Items collection
DropDownList1.Items[0].Value
DropDownList1.Items[DropDownList1.Items.Count].Value
Hope this helps- Hide quoted text -

- Show quoted text -
Sorry, I think I did a mistake, collection index is a zero-based and
you need to use

DropDownList1.Items[DropDownList1.Items.Count-1].Value

to get the last item in the list.

Note, you would need to check the size of the Items collection....

If DropDownList1.Items.Count>0 Then
.....

Alexey
Jun 27 '08 #4

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

Similar topics

1
by: dw | last post by:
I want to create a databound dropdown list with "Yes" = 1 and "No" = 0. I set the collection up with the two values and databind it to a binary field (sql server) and the only entry in dropdown...
11
by: David Messner | last post by:
Ok I know this is simple but the statement eludes me... I have a date field where I want the default value on the data entry form's date field to be the last date entered. I figure I can do this...
1
by: Lars Pedersen | last post by:
Hi! Have can i select an item in a DropDown List, based on a datavalue. thanks -Lars
2
by: hypomite | last post by:
I have an handler for the SelectedIndexChanged event of a dropdown box. I have also set the AutoPostBack option to True. When you select any item besides the first one, the event sucessfully fires....
2
by: Christos via AccessMonster.com | last post by:
Dear friends I would like to find the first and the last element of a record in a table. Is there any possibility especially if yoy have not promary key? Christos -- Message posted via...
2
by: Alex | last post by:
Hello all, I'm at a loss on how to do this. We're using MS SQL 2000 Server and I have a list of fields I need to find the first and last entry for. Here's an example of the table: Number -...
17
by: Timothy.Rybak | last post by:
Hello all, This is my first attempt at an application, so kid gloves are appreciated. I need to make a very simple form that only has a few elements. One is TraceCode - a text field that is...
3
by: webmaster | last post by:
Pardon my not knowing where to find this one... but try finding the meaning of "this" on the net or in reference books. I'm trying to follow this example from Apress book - Introduction to C#...
3
by: mckbill | last post by:
Is there a way I can direct the cursor to a specific field (variable) in a form by typing the field name while in form view? I have a form with many fields, and it would be nice if there were...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.