?
Solved

How to bind a string array to a drop down list

Posted on 2010-11-20
5
Medium Priority
?
330 Views
Last Modified: 2012-05-10
I need to bind and string array to a drop down list .
0
Comment
Question by:Ammar Iqbal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 18

Expert Comment

by:Richard Lee
ID: 34179305
Just bind as normal. The string becomes the value and the text.

<asp:DropDownList ID="ddlList" runat="server" />

DaTribe
List<string> items = new List<string>
	{"One", "Two", "Three"};

ddlList.DataSource = items;
ddlList.DataBind();

Open in new window

0
 
LVL 11

Accepted Solution

by:
SAMIR BHOGAYTA earned 2000 total points
ID: 34179550
Hello, You have to try this code

string[] myStrings = new string[] {"string1", "string2", "string3"};

DropDownList ddl = new DropDownList();

ddl = (DropDownList)e.Row.FindControl("ddlMyStrings");

ddl.DataSource = myStrings;

ddl.DataBind();
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 34179552
                 array<String^>^ ar = {("one"), "two", "three"};
                  comboBox1->DataSource = ar;
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 34179554
Oh, that is C++.net code - you posted into a C++.net area as well as C#

Did you require C# code ?
0
 
LVL 1

Author Comment

by:Ammar Iqbal
ID: 34179555
Yes I have done it already, Forgot to delte this question. Anyways I ma accepting your answer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question