?
Solved

dropdown list and datasource

Posted on 2012-04-04
2
Medium Priority
?
306 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
[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
2 Comments
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 800 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 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

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