Solved

dropdown list and datasource

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

746 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

13 Experts available now in Live!

Get 1:1 Help Now