﻿
HTMLSelectElement.prototype.Bind = function(dataSource, valueProperty, textProperty, selectOption) {
    var items = [];
    if (dataSource.GetEnumerator) {
        var en = dataSource.GetEnumerator();
        while (en.MoveNext()) {
            var item = {};
            item.value = valueProperty ? en.Current[valueProperty] : en.Current;
            item.text = textProperty ? en.Current[textProperty] : en.Current;
            item.__NoSeparator = en.Current['__NoSeparator'];
            items.push(item);
        }

        this.Clear();
        this.options.add(new Option(selectOption, selectOption));
        for (var i = 0; i < items.length; i++) {
            this.options.add(new Option(items[i].text, items[i].value));
        }

    }
}

HTMLSelectElement.prototype.Clear = function() {
    this.options.length = 0
}

HTMLSelectElement.prototype.SetDisabled = function() {
    this.disabled = true;
}

HTMLSelectElement.prototype.SetEnabled = function() {
    this.disabled = false;
}

HTMLSelectElement.prototype.SelectedValue = function() {
    return this.options[this.selectedIndex].value;
}