﻿function bindDropDownList(e, targetDropDownList) {

    var key 
    var allOptions = targetDropDownList.allOptions;
    var option;
    var newOption;
    var selectValue = -1;
    targetDropDownList.options.length = 0;

    if (this.value == null) {
        key = e.value;
    } else {
        key = this.value;
    }

    newOption = new Option("", "");
    targetDropDownList.options.add(newOption);
   
    for (var i=0; i < allOptions.length; i++) 
    {
        option = allOptions[i];
        if (option.key == key) 
        {
            newOption = new Option(option.text, option.value);
            newOption.selected = (option.selected == '1');
            targetDropDownList.options.add(newOption);
        }
    }
}