
function bindSingleData(contain, objData) {
    var dataControlArray = getDataControls(contain);
    for (var i = 0; i < dataControlArray.length; i++) {
        var item = dataControlArray[i];
        if (objData[item.Name] !== undefined) {
            var value = null;
            try{            
                eval("var time =new " + objData[item.Name].replace("/", "").replace("/", ""));
                value = time.Format("yyyy-MM-dd");
            }
            catch(e){
                value = objData[item.Name];
            }
            item.Control.val(value);
        }
    }
}

function getSingleData(containd) {
    var result = new Object();
    var dataControlArray = getDataControls(containd);
    for (var i = 0; i < dataControlArray.length; i++) {
        var item = dataControlArray[i];
        result[item.Name] = item.Control.val();
    }
    return result;
}

function getDataControls(contain) {
    var result = new Array();
    var textArray = contain.find("input[type='text']");
    var hiddenArray = contain.find("input[type='hidden']");
    var passwordArray = contain.find("input[type='password']");
    var checkboxArray = contain.find("input[type='checkbox']");
    var selectArray = contain.find("select");
    var textareaArray = contain.find("textarea");
    textArray.each(function(i) {
        var item = textArray.eq(i);
        var itemName = item.attr("name");
        if (itemName) {
            var obj = new Object();
            obj.Name = itemName;
            obj.Control = item;
            result.push(obj);
        }
    });
    hiddenArray.each(function(i) {
        var item = hiddenArray.eq(i);
        var itemName = item.attr("name");
        if (itemName) {
            var obj = new Object();
            obj.Name = itemName;
            obj.Control = item;
            result.push(obj);
        }
    });
    passwordArray.each(function(i) {
        var item = passwordArray.eq(i);
        var itemName = item.attr("name");
        if (itemName) {
            var obj = new Object();
            obj.Name = itemName;
            obj.Control = item;
            result.push(obj);
        }
    });
    checkboxArray.each(function(i) {
        var item = checkboxArray.eq(i);
        if (!item.attr("checked")) {
            return;
        }
        var itemName = item.attr("name");
        if (itemName) {
            var obj = new Object();
            obj.Name = itemName;
            obj.Control = item;
            result.push(obj);
        }
    });
    selectArray.each(function(i) {
        var item = selectArray.eq(i);
        var itemName = item.attr("name");
        if (itemName) {
            var obj = new Object();
            obj.Name = itemName;
            obj.Control = item;
            result.push(obj);
        }
    });
    textareaArray.each(function(i) {
    var item = textareaArray.eq(i);
        var itemName = item.attr("name");
        if (itemName) {
            var obj = new Object();
            obj.Name = itemName;
            obj.Control = item;
            result.push(obj);
        }
    });
    return result;
}