In my ASP.Net C# project I have a requirement to display a dropdown containing both people’s names and office names.
When the user makes a selection, the event is handled in JavaScript and used to filter the results of a grid. So if the user selects a person’s name from the dropdown then the grid displays only the results for that person. If the user selects an office then the grid should show the results for all the people in that office.
The filtering is handled in JavaScript on the OnClientDropDownClosed event of the dropdown.The grid and dropdown are Telerik controls not standard ones BTW.
My question is – what is the best way to determine what type of item the user has selected.
The Value for the dropdown item is either the person’s name or the office identifier.
I’m thinking I could simply add a prefix to the Value and do a substring test for it but that seems a little hacky…
is there a better way to achieve what I want?
As there is a chance that office name and person name can be same, so we can’t do a cross check on client side.
So my suggestion is to multiple office values with -1, so that office Ids are in negative, when a user selects a value, simply check if value is below 0 than wow its an office otherwise its a person 🙂