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
Solved

SRTING DROPDOWN LIST

Posted on 2014-10-17
3
46 Views
Last Modified: 2014-10-23
Please review code below.   I need to sort the data in dropdown lists for "CondBY" and "InspBy" in "ASCENDING ORDER" or alphabetical order.   I need assistance with this code.

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            FillDropdown(CondBY);
            FillDropdown(InspBy1);

        }

    }

        con.Open();
        SqlCommand cmd = new SqlCommand("select * from EmpData", con);
        SqlDataAdapter dap = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        dap.Fill(ds);
        ddl.DataSource = ds;
        ddl.DataTextField = "Name1";//Database table filed name for display in dropdown
        ddl.DataValueField = "EmpNo";//display in textbox when select dropdown field
        ddl.DataBind();

    }

    protected void CondBY_SelectedIndexChanged(object sender, EventArgs e)
    {
        EmpAP.Text = CondBY.SelectedValue.ToString();// get value form dropdown

    }
    protected void InspBy1_SelectedIndexChanged(object sender, EventArgs e)
    {
        EmpAP1.Text = InspBy1.SelectedValue.ToString();// get value form dropdown
    
 
    }

}

Open in new window

0
Comment
Question by:BOEING39
  • 2
3 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40388631
If you are getting that data from the database, then you could sort it there.
0
 

Accepted Solution

by:
BOEING39 earned 0 total points
ID: 40388739
Thx I sorted it via the select statement per below:  


("select * from EmpData order by Name1", con);
0
 

Author Closing Comment

by:BOEING39
ID: 40398952
Researched solution on the web.  Statement solution was the best explanation and associated code to resolve problem.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
Question! 4 39
Need to start a web service from Visual Studio 2015 Pro 2 35
VB.NET - Refactor Class per SOLID principles 2 21
Problem to Office 1 14
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

838 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