Hello All,
I have a use case that requires an Agent. The agent can be a person or a company. The issue that I have is that I need to order/sort an NVL BO by name or number. I have solved that issue; however, if the agent is a company, the CompanyName field is used and, if the agent is a person, the LastName and FirstName fields are used. Therefore, when the order/sort by name occurs, the "Company Agents" appear in the list first because the LastName and FirstName fields are "String.Empty".
I am using two different stored procedures to return the data for the BO: one that orders by AgentNumber and one that orders by LastName, FirstName, CompanyName. When I use the BO in the UI, I call AgentNVL.GetAgentList(False) to sort by "Number" and AgentNVL.GetAgentList(True) to sort by "Name".
How do I force the CompanyName field to sort with the LastName. For instance, I have the following data:
AgentNumber LastName FirstName CompanyName
0001 Williams John
0002 Williams Amy
0003 Winton Corporation
That is how it looks using the order/sort by AgentNumber, but whenever the NVL is ordered/sorted by "Name", I get "0003" listed first, "0002" second, and then "0001". It should be listed with "0002" first,"0001" second, and "0003" last.
Any help is greatly appriciated.
Kelly.
Hey Andy,
I don't think I'm quite ready to tackle that one yet (at least "level-of-knowledge-wise" anyway). I would not even know where to start. Thanks for the idea though; I may have to use that as a last resort.
Kelly.
You could create a name field that returns a company name for a company and the last name + first name for a person. You would sort by name. I not sure it this is what you exactly want, but it is an alternative to what you are doing.
That is basically what I'm doing. I put a check in for the string.length of the fields and if the company name is > 0 then I use the CompanyName and if the last name is > 0 I use LastName, FirstName. But how do I tell the NVL to sort after the data has been returned from the stored proc? Do I sort the list from the UI or sort in BO after the list is populated? Not sure I know how to do that in the BO. I'm sure that would be the best place to do it because there could be eight or ten thousand agents. I would think that it would take at least a few seconds to sort it in the UI, don't you think?
Kelly.
Thanks Andy,
I'll try the SortedBindingList first. Then, I'll try the IComparable route just to see which is better.
Thanks for the advice.
Kelly.
Copyright (c) Marimer LLC