开发者

How do I sort and add unique array options to a DropDownList using jQuery?

I have an array of objects “AllClaimants” that has 2 properties (UserInfo & UserID);

Example:

AllClaimants[AllClaimantsCounter].UserInfo = "Santhalingam Sugirtha, 1980-06-05";
AllClaimants[AllClaimantsCounter].UserID = "1076073";

My AllClaimants[AllClaimantsCounter].UserInfo information contains 2 things “Name + Date of Birth”.

How can I sort (by UserInfo - in Userinfo I want to sort it by Name part only not by Date of Birth) and add unique values to select dropdown (ClaimantsDropDown) with text as开发者_如何转开发 AllClaimants[AllClaimantsCounter].UserInfo and value as AllClaimants[AllClaimantsCounter].UserID?

Thanks


You could convert the array to List with

Array.AsList(array) 

and the use linq with something like

list.OrderBy(x=> x.Key)

And depend on the type of the dropdrown you have to fill it, if it is a dropdown from aspnet server control you could use the list as datasource.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜