Drop-down box to remove duplicate

Drop-down box to remove duplicate

文献种类:专题技术文献;
开发工具与关键技术:Vs
作者:蛋蛋;
撰写时间:2019/06/07

What is the drop-down box?
There query page as the query conditions in the drop down box, as a result of the query conditions;
good method is generally used when we directly encapsulated in the drop-down box query transactions; drop-down box is used as selected; duplicate data inevitable, but some of the time call SelectVo, an ID, a name name; ID as the selected value, name is the display value of the text type;
createSelect: The method is to create a drop-down box according to the URL;
createSelect () has three parameters (selictId, URL, value,)
selictId is the form the form id, url: path, query path drop-down box; value, set value
but it is clearly a field there are several elements but very much so how do we deal with it? Here Insert Picture Description
Look legend, this drop-down box in the customer data significantly among the categories of content to repeat, there are individual customers and corporate customers two content but because of the number of data bars and more and show all, so if the data is enormous when it will bring to unnecessary trouble; so we need a little deal, wrote an entity class named myOption
expand:Is a label, Option element at a given option (one entry) in the list, appears as an element label menu or scrolling list; in turn create a list of objects and entity objects, a different note is to create an entity object id = ""
instead assigned 0; text or splicing "- select -",
Here Insert Picture Description
and select slightly similar wording, changed the name and id = "" written in the controller which also need to take note
// query data
List listClientGenre = (from tbClientSort in myModels.S_Client
SELECT new new myoption
{ID = tbClientSort.ComparnyName,
text = tbClientSort.ComparnyName
}) the Distinct () ToList ();.. // deduplication

Id should be noted that not id = tbClientSort.ClientID; but directly name; here there is a new vocabulary "Distinct ()" Distinct This is a keyword used to filter out unwanted duplicate records leaving only a ; but often it only returns the number of unique records, rather than use it to return all the values are not re-record, the reason is Distinct can only return to his target field you can not return other fields. The next option is still the same stitching, listClientGenre = Common.Tools.SetOptionJson (listClientGenre); return Json (listClientGenre, JsonRequestBehavior.AllowGet); this was written, only minor modifications mainly to the use of Distinct keyword to see the final result Figure:
Here Insert Picture Description
so that our drop-down box to repeat is realized!

Guess you like

Origin blog.csdn.net/qq_42577408/article/details/91128520