Solved

SRTING DROPDOWN LIST

Posted on 2014-10-17
3
48 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
[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
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

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

Suggested Solutions

Title # Comments Views Activity
linq, c# 8 37
.NET Enums [Flags] & Bitwise Design Question 6 39
How to set focus on a dynamic control 18 28
c#  FTP ftpwebrequest URI invalid 6 15
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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