Solved

dropdown list and datasource

Posted on 2012-04-04
2
303 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 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

Technology Partners: 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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

735 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