Solved

dropdown list and datasource

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

688 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