Solved

dropdown list and datasource

Posted on 2012-04-04
2
299 Views
Last Modified: 2012-04-05
I have two dropdown boxes on the web page, after click Go button, it will list some informatin in a table.  There are really not much information, only about 40 items.  What datasource should I use to bind with dropdown box except database?  I tried not to use a database, since it only about 40 items.  Thank you.
0
Comment
Question by:5281
2 Comments
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 200 total points
ID: 37808574
If you really don't want to use a database then I would suggest using a xml datasource see the link for an example :

http://www.ezineasp.net/post/ASP-Net-DropDownList-XML-DataSource-Databinding.aspx
0
 
LVL 19

Assisted Solution

by:Manoj Patil
Manoj Patil earned 50 total points
ID: 37808587
If these are static or limited to 40 only then you can try with enum like following
public enum Color
{
    RED,
    GREEN,
    BLUE
}

Open in new window




    protected System.Web.UI.WebControls.DropDownList ddColor;

    private void Page_Load(object sender, System.EventArgs e)
    {
         if(!IsPostBack)
         {
            ddColor.DataSource = Enum.GetNames(typeof(Color));
            ddColor.DataBind();
         }
    }

Open in new window



Finally

 private void ddColor_SelectedIndexChanged(object sender, System.EventArgs e)  {   Color selectedColor = (Color)Enum.Parse(ddColor.SelectedValue);   }
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.
Send secure, cloud-based, encrypted alerts and maintain HIPAA compliant messaging. Integrates priority & secure messaging into one application. Ensures IT, emergency respondents and healthcare professionals that their critical messages are never mis…

914 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now