473,738 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

binding datasource to dropdownlist control

I am being sent an ArrayList of ListItems.

I can bind to a dropdownlist control using:

oDropDownList.D ataSource = 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 9696
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********@yah oo.com> wrote in message
news:fL******** ************@gi ganews.com...
I am being sent an ArrayList of ListItems.

I can bind to a dropdownlist control using:

oDropDownList.D ataSource = 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.c o.in> wrote in message
news:Oe******** ******@TK2MSFTN GP10.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********@yah oo.com> wrote in message
news:fL******** ************@gi ganews.com...
I am being sent an ArrayList of ListItems.

I can bind to a dropdownlist control using:

oDropDownList.D ataSource = 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
3094
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 icollection...but i thought list boxes did implement one of the above as they do have their items collection property, can anyone help?
0
4792
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 TemplateColumn with a DropDownList (DDL) in the FooterItemTemplate that is populated in the Page_Load event using a Sub Routine as the DataSource of the DDL. The FooterItemTemplate's DDL populates as expected when the DataGrid's DataBind method is called. ...
1
1445
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 the explanation is not useful. Please spend sometime reviewing this question and its answer. Any guide on this matter would be greatly appreciated. Question: Your Web form includes a DropDownList control named ddlStudent that displays a...
0
982
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 the explanation is not useful. Please spend sometime reviewing this question and its answer. Any guide on this matter would be greatly appreciated.
5
18540
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" ConnectionString="<%$ ConnectionStrings:cnnSQL_Connect %>" Runat="server"> <SelectParameters> <asp:Parameter Type="String" DefaultValue="FindWebDocAll"
5
4230
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); System.Data.SqlClient.SqlCommand dbCommand1 = new System.Data.SqlClient.SqlCommand();
9
5338
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 (filtered) dependent upon the selection in DDL1. I think this inevitably needs some code, but I'd be happy to be told otherwise! I have some code to handle OnSelectedIndexChanged for DDL1 that sets the FilterExpression associated with the...
6
5744
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 to a DataSet. If i include an if statement to prevent the data binding from occuring on a page PostBack in the following way:
2
1873
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 procedure. The stored procedure takes an ID of a selected item (@BoundID) from the dropdownlist and gives a result (@BoundIdentifier) as follows: --- Running . ( @BoundID =
0
8968
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8787
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9473
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8208
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4569
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.