<select id="<%= this.ClientID %>Select" name="<%= this.UniqueID %>Select" class="form-control"></select>
<asp:HiddenField ID="hiddenField" runat="server" />

<%--
<link href="../assets/select2-develop/dist/css/select2.min.css" rel="stylesheet" />
<link href="../assets/select2-bootstrap-theme-master/dist/select2-bootstrap.min.css" rel="stylesheet" />
<script src="../assets/select2-develop/dist/js/select2.min.js"></script>
<script src="../assets/select2-develop/dist/js/i18n/zh-CN.js"></script>
--%>

<script type="text/javascript">
    $(function () {
        $('#<%= this.ClientID %>Select').select2({
            ajax: {
                url: '../App_Handler/DropDownListCompany.ashx',
                dataType: 'JSON',
                data: function (params) {
                    return {
                            <%= Eastupright.Crane.BLL.Company.WhereField.CompanyNameLike %>: params.term,
                            <%= Eastupright.Crane.BLL.Company.WhereField.BusinessNumberLike %>: params.term
                    };
                },
                processResults: function (data) {
                    return {
                        results: data
                    };
                }
            },
            language: 'zh-CN',
            theme: 'bootstrap',
            width: '100%',
            minimumInputLength: 2,
            escapeMarkup: function (data) {
                return data;
            },
            placeholder: '请选择...',
            allowClear: true
        })
            .on('change', function (e) {
                $('#<%= hiddenField.ClientID %>').val($('#<%= this.ClientID %>Select').val()).trigger('change');
            });

        if ($('#<%= hiddenField.ClientID %>').val() != '') {
            $('#<%= this.ClientID %>Select').append(new Option('<%= Eastupright.Crane.BLL.Company.ToString(Value) %>', $('#<%= hiddenField.ClientID %>').val(), true, true)).trigger('change');
        }

        $.fn.modal.Constructor.prototype.enforceFocus = function () { };
    });
</script>

                List<object> response = new List<object>();
                {
                    foreach
                        (
                            Model.Company item in BLL.Company.GetModelList
                            (
                                BLL.Company.Where(context.Request.QueryString, BLL.BCL.WhereType.OR)
                                +
                                BLL.BCL.Order
                                (
                                    new KeyValuePair<string, BLL.BCL.OrderType>(BLL.Company.Field.CompanyName, BLL.BCL.OrderType.ASC)
                                )
                            )
                        )
                    {
                        response.Add
                            (
                                new
                                {
                                    id = item.GUID,
                                    text = BLL.Company.ToString(item.GUID)
                                }
                            );
                    }
                }