get first and last datavalue field entry of dropdown box

P

Paul

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.
 
G

Guest

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.

Hi Paul

I think, you can use Items collection

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

Hope this helps
 
P

Paul

I think that is what I was looking for, thanks.
--
Paul G
Software engineer.


Anon User said:
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.

Hi Paul

I think, you can use Items collection

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

Hope this helps
 
G

Guest

I think that is what I was looking for, thanks.
--
Paul G
Software engineer.



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
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top