function OnGridSelectionChanged(Type) {
    if (Type == 0) {
        gvSensorAssign.GetSelectedFieldValues('SensorId', OnGridSelectionCompleteSensorAssign);
    }
    if (Type == 1) {
        gvSensorUnAssign.GetSelectedFieldValues('SensorId', OnGridSelectionCompleteSensorUnAssign);
    }
    if (Type == 2) {
        gvOutputAssign.GetSelectedFieldValues('OutputId', OnGridSelectionCompleteOutputAssign);
    }
    if (Type == 3) {
        gvOutputUnAssign.GetSelectedFieldValues('OutputId', OnGridSelectionCompleteOutputUnAssign);
    }
}

function OnGridSelectionCompleteSensorAssign(values) {
    var counter = document.getElementById("hdnSelectedSensorAssignIds");
    counter.value = '';
    for (var i = 0; i < values.length; i++) {
        counter.value = counter.value + values[i] + ',';
    }
}

function OnGridSelectionCompleteSensorUnAssign(values) {
    var counter = document.getElementById("hdnSelectedSensorUnAssignIds");
    counter.value = '';
    for (var i = 0; i < values.length; i++) {
        counter.value = counter.value + values[i] + ',';
    }
}

function OnGridSelectionCompleteOutputAssign(values) {
    var counter = document.getElementById("hdnSelectedOutputAssignIds");
    counter.value = '';
    for (var i = 0; i < values.length; i++) {
        counter.value = counter.value + values[i] + ',';
    }
}

function OnGridSelectionCompleteOutputUnAssign(values) {
    var counter = document.getElementById("hdnSelectedOutputUnAssignIds");
    counter.value = '';
    for (var i = 0; i < values.length; i++) {
        counter.value = counter.value + values[i] + ',';
    }
}

function ValidateSensorOutputAssign(type) {

    if (DeviceValidation(true) == false)
        return false;

    if (type == "Sensor") {
        return CheckSelectionForManipulation(9);
    }
    else {
        return CheckSelectionForManipulation(11);
    }
}