Solved

How to bind a string array to a drop down list

Posted on 2010-11-20
5
320 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 500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
c#, datatable, aspx 4 46
Need some help with design 17 44
How do i create a simple array in a public class? 6 32
history of pages 7 47
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

736 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