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

binding datasource to dropdownlist control

I am being sent an ArrayList of ListItems.

I can bind to a dropdownlist control using:

oDropDownList.DataSource = oArrayList

This works but when the dropdownlist is rendered both the select box value
and the text are the same (The ListItem.Text), How do I get the
ListItem.Text to render as the text and the ListItem.Value to be the html
select option 'value'?

Thank You,
Stan
Nov 17 '05 #1
2 9672
Use DataTextField and DataValueField properties of dropdownlist to assign
text and value for dropdownlist.

--
Saravana
Microsoft India Community Star,
MCAD,SE,SD,DBA.
"DesignerX" <de********@yahoo.com> wrote in message
news:fL********************@giganews.com...
I am being sent an ArrayList of ListItems.

I can bind to a dropdownlist control using:

oDropDownList.DataSource = oArrayList

This works but when the dropdownlist is rendered both the select box value
and the text are the same (The ListItem.Text), How do I get the
ListItem.Text to render as the text and the ListItem.Value to be the html
select option 'value'?

Thank You,
Stan

Nov 17 '05 #2
Saravana,

Thanks for the reply, unfortunately that is my problem... I do not know how
to use the DataValueField property without looping thru the entire
ArrayList. With an ArrayList of ListItems, how would I use the
DataValueField to refer property to refer to a property of the object within
the array?

Thanks,
Stan

"Saravana" <sa******@sct.co.in> wrote in message
news:Oe**************@TK2MSFTNGP10.phx.gbl...
Use DataTextField and DataValueField properties of dropdownlist to assign
text and value for dropdownlist.

--
Saravana
Microsoft India Community Star,
MCAD,SE,SD,DBA.
"DesignerX" <de********@yahoo.com> wrote in message
news:fL********************@giganews.com...
I am being sent an ArrayList of ListItems.

I can bind to a dropdownlist control using:

oDropDownList.DataSource = oArrayList

This works but when the dropdownlist is rendered both the select box value and the text are the same (The ListItem.Text), How do I get the
ListItem.Text to render as the text and the ListItem.Value to be the html select option 'value'?

Thank You,
Stan


Nov 17 '05 #3

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

Similar topics

10
by: ShadowsOfTheBeast | last post by:
hi all i am trying to bind data to my datagrid from a listbox which i think it should work but an error is coming up saying i have to bind to a datasource that implements the Inumerable or...
0
by: Shane O. Pinnell | last post by:
I am sure this has come up before, but I haven't been able to find an answer as of yet. That said, any help is definitely appreciated! I have a datagrid populated from a dataset. I have a...
1
by: Moshfegh Hamedani | last post by:
Hi there, I found this question in Amit Kalani's preparation book for exam 70-15 (Developing Web Applications with C#). I think it's a very stupid question! It says the correct answer is A but...
0
by: Moshfegh Hamedani | last post by:
Hi there, I found this question in Amit Kalani's preparation book for exam 70-15 (Developing Web Applications with C#). I think it's a very stupid question! It says the correct answer is A but...
5
by: sck10 | last post by:
Hello, I have a GridView that is using the following to connect to a SQL Server 2000 stored procedure: <asp:SqlDataSource ID="dsWebDocList" SelectCommand="sp_web_WebDocument"...
5
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
9
by: Timm | last post by:
I have an ASP.NET 2.0 page with two DropDownLists. I am using declarative data binding wherever possible and trying to minimize the use of code. The list of values in DropDownList DDL2 should be...
6
by: p.mc | last post by:
Hi all, I'm having major problems with a userControl which contains a datagrid. My problem concerns data binding. The Page_Load() procedure calls the DataBind procedure to bind the datagrid...
2
by: Igor | last post by:
Hi I build a page that has a dropdownlist control bound with data from a database. When user select an item from the dropdownlist I want a label to be filled with a result from a stored...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.