The value and binding method of combobox in the JQueryEasyUI framework. easyuicombobox Value

Source: Internet
Author: User

The value and binding method of combobox in the JQueryEasyUI framework. easyuicombobox Value

Recently, the project involves the use of the JQueryEasyUI framework. What is EasyUI? It is an easy-to-use and powerful lightweight WEB Front-end JavaScript framework from the W3C standard WEB Front-end expert DHTML elite club! From the understanding of this sentence, I think it is a JavaScript framework.

In my recent use, EasyUI is a collection of jQuery User Interface plug-ins, which I understand as a plug-in, I don't know if there is any problem. When easyui is used, you do not need to write a lot of javascript code. You only need to write some HTML tags on the defined user interface to complete the HTML5 webpage framework. Therefore, there is no server control in this framework. No ruant = "server ". It is powerful and easy to use.

The following describes how to obtain the value and bind the value in the combobox in the EasyUI framework.

At the front-end, we usually write as follows:

<select class="easyui-combobox" id ="cmbName" name="name" ></select>

The Data Binding problem in the control was introduced in the niugu news and publishing system and in Beida qingniao. Can this method be used here? Both the NIU news publishing system and the control mentioned in Beida qingbird are server controls, but this is not a server control. How can we bind and obtain values?

Bind value: (more than this method)

You can convert this control to a server control. Add runat = "server" and install it as a server control. The rest will be the same as the server control mentioned in the niugu news and publishing system and in the Beida qingbird.

Copy codeThe Code is as follows:
<Select class = "easyui-combobox" id = "cmbName" runat = "server" datatextfield = "AdminName" datavaluefield = "AdminID" name = "name" style = "width: 150px; "> </select>

Background:

 protected void Page_Load(object sender, EventArgs e)     {         noticeInfoBLL Bnotice = new noticeInfoBLL();         DataSet ds = new DataSet();         ds = Bnotice.GetAllList();         DataTable dt = ds.Tables[0];         cmbName.DataSource =dt;         cmbName.DataTextField = "AdminName";         cmbName.DataValueField = "AdminID";         cmbName.DataBind();     }

After binding a value, how can I get the value in it?

Get value:

Var adminname = $ ("# state "). combobox ("getText"); // This is the content selected in the combobox, for example, the "AdminName" var adminid = $ ("# state") bound above "). combobox ("getValue"); // This is the value selected by combobox, for example, the "AdminID" bound above"

The comboboxc binding value is repeated:

When I bind a value to combobox, I still encounter this problem. There are many records in the returned data, because I bound the names to combobox and the names cannot be repeated, however, the data returned from the database is as follows:

So how can we solve this problem?

There are two solutions:

1. Modify the query statement and use the SQL SELECT DISTINCT statement.

Second, you can bind data in the background as follows:

Protected void Page_Load (object sender, EventArgs e) {// if (! Page. IsPostBack) // if (Session ["userid"]! = Null & Session ["postid"]! = Null) noticeInfoBLL Bnotice = new noticeInfoBLL (); DataSet ds = new DataSet (); ds = Bnotice. getAllList (); DataTable dt = ds. tables [0]; // deduplicate AdminName and AdminID DataView dv = dt. defaultView; cmbName. dataSource = dv. toTable (true, "AdminName", "AdminId"); cmbName. dataTextField = "AdminName"; cmbName. dataValueField = "AdminID"; cmbName. dataBind ();}

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.