Binding drop-down box


开发工具与关键技术:vs2015  MVC

作者:陈星宇

撰写时间:2019.5.18

Binding drop-down box, we often use, so I am here to talk about the detailed process of binding drop-down box, select First we create a label, then I select the label id give good easy to operate behind.

Here Insert Picture Description
Then we can create a method, because a lot of drop-down box where the binding will be used, then we can build a drop-down box function to facilitate global use,

The first is a function of the contents inside getJson data submitted, the drop-down box to select the option sure to have the data, then the way we use the data submitted to the controller which we want to query the data
Here Insert Picture Description

Here I also used the method to clear drop-down box of empty elements, back to the first drop-down box select a binding text of.
In the query select new in the field must be assigned to the id, and text
Here Insert Picture Description
so that our method can be received, check out the data.
After the query data, we can use a method binding loop will check out the data to the drop-down box,
here we are using each method is circulated.
Here Insert Picture Description
Here are the contents of the value assigned to the value id, setting text to the display value, from here you can see the field when we queried why is assigned to the query of the value of the id and text.
Here the parameters of this method we give him two values is the id of a url and
Here Insert Picture Description
we call the function when direct write url id and then you can complete the binding of the drop-down box.
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/tianxiu11/article/details/90244660