# UltraCombo sort in method?

**URL:** <https://www.epiusers.help/t/ultracombo-sort-in-method/40939>\
**Category:** Epicor ERP 10\
**Created:** [October 18, 2017, 10:15pm UTC](https://www.epiusers.help/t/ultracombo-sort-in-method/40939 "2017-10-18T22:15:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pbparker](https://www.epiusers.help/user_avatar/www.epiusers.help/pbparker/32/256_2.png) [@pbparker](https://www.epiusers.help/u/pbparker)\
**Post date:** [October 18, 2017, 10:15pm UTC](https://www.epiusers.help/t/ultracombo-sort-in-method/40939/1 "2017-10-18T22:15:52Z")

</div>

I searched for a solution but found varied incomplete answers, so sorry if this was somewhere blatantly obvious.

I’m populating a dropdown with employees and displaying the employee name but storing the employee id. The data is coming back not sorted by the visible name and likely by the ID. Is there a way to sort the data directly in the method call? I’ve used the whereClause to filter my results, hoping there’s a quick way of adding the sort there as well.

Call is below.

```
private void SearchOnPREmployeeAdapterFillDropDown()
{
	bool recSelected;
	string whereClause = string.Empty;
	whereClause = String.Format("ExpenseCode = '1400'");
	System.Data.DataSet dsPREmployeeAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "PREmployeeAdapter", out recSelected, false, whereClause);
	if (recSelected)
	{
		// Set EpiUltraCombo Properties
		this.epiUltraComboC1.ValueMember = "EmpID";
		this.epiUltraComboC1.DataSource = dsPREmployeeAdapter;
		this.epiUltraComboC1.DisplayMember = "Name";
		string[] fields = new string[] {
				"Name"};
		this.epiUltraComboC1.SetColumnFilter(fields);
	}
}
```

---

<div class="post-metadata">

**Author:** ![bw2868bond](https://www.epiusers.help/user_avatar/www.epiusers.help/bw2868bond/32/277_2.png) [@bw2868bond](https://www.epiusers.help/u/bw2868bond)\
**Post date:** [October 18, 2017, 10:57pm UTC](https://www.epiusers.help/t/ultracombo-sort-in-method/40939/2 "2017-10-18T22:57:24Z")

</div>

> [@pbparker](#):
>
> whereClause = String.Format(“ExpenseCode = ‘1400’”);

can you add the sort to the where clause?  
whereClause = String.Format(“ExpenseCode = ‘1400’ ORDER BY Name”);

---

<div class="post-metadata">

**Author:** ![pbparker](https://www.epiusers.help/user_avatar/www.epiusers.help/pbparker/32/256_2.png) [@pbparker](https://www.epiusers.help/u/pbparker)\
**Post date:** [October 19, 2017, 12:53am UTC](https://www.epiusers.help/t/ultracombo-sort-in-method/40939/3 "2017-10-19T00:53:11Z")

</div>

No, throws an error. I tried that initially hoping it would be that easy.

Error is:  
Incorrect syntax near the keyword ‘ORDER’.

---

<div class="post-metadata">

**Author:** ![bw2868bond](https://www.epiusers.help/user_avatar/www.epiusers.help/bw2868bond/32/277_2.png) [@bw2868bond](https://www.epiusers.help/u/bw2868bond)\
**Post date:** [October 19, 2017, 1:16am UTC](https://www.epiusers.help/t/ultracombo-sort-in-method/40939/4 "2017-10-19T01:16:58Z")

</div>

How about BY Name – without ORDER

---

<div class="post-metadata">

**Author:** ![pbparker](https://www.epiusers.help/user_avatar/www.epiusers.help/pbparker/32/256_2.png) [@pbparker](https://www.epiusers.help/u/pbparker)\
**Post date:** [October 19, 2017, 1:37am UTC](https://www.epiusers.help/t/ultracombo-sort-in-method/40939/5 "2017-10-19T01:37:10Z")

</div>

LOL, yes that does in fact work. With my SQL thinking I don’t know that I would have considered that, much thanks.
