Error: System.IndexOutOfRangeException: Index was outside the bounds of the array

Get this error on a Submit button click event
How do I fix this?

              protected void btnSumbit_Click(object sender, EventArgs e)
    {
        if (cboEmployees.SelectedIndex == 0 || cboForeman.SelectedIndex == 0 || cboOSA.SelectedIndex == 0)
        {
            lblInformation.Text = "Please make sure that all necessary fields are filled out and all hours entered are numeric";
            return;
        }

        if (string.IsNullOrEmpty(txtDate.Text) || string.IsNullOrEmpty(txtJobNumber.Text) ||
            string.IsNullOrEmpty(txtContractHours.Text) || string.IsNullOrEmpty(txtRainHours.Text) ||
            string.IsNullOrEmpty(txtOtherHours.Text))
        {
            lblInformation.Text = "Please make sure that all necessary fields are filled out and all hours entered are numeric";
            return;
        }

        double d;

        if (!double.TryParse(txtContractHours.Text, out d) ||
            !double.TryParse(txtOtherHours.Text, out d) ||
            !double.TryParse(txtRainHours.Text, out d))
        {
            lblInformation.Text = "Please make sure that all necessary fields are filled out and all hours entered are numeric";
            return;
        }

        DateTime dt;

        if (!DateTime.TryParse(txtDate.Text, out dt))
        {
            lblInformation.Text = "Please make sure that all necessary fields are filled out and all hours entered are numeric";
            return;
        }

        string[] array = cboEmployees.Text.Split(',');

        EmployeeHours hours = new EmployeeHours();
        hours.JobNumber = txtJobNumber.Text;
        hours.ContractHours = double.Parse(txtContractHours.Text);
        hours.MillerHours = double.Parse(txtRainHours.Text);
        hours.TravelHours = double.Parse(txtOtherHours.Text);
        hours.TimeCardDate = txtDate.Text;

        PayrollManager payrollManager = new PayrollManager(DateTime.MinValue, DateTime.MinValue, array[1], array[0]);
        //payrollManager.ProcessNewPayrollEntry(Int64.Parse(cboEmployees.SelectedValue), hours, cboOtherReasons.Text, txtNotes.Text, cboForeman.Text, cboOSA.Text, txtAltJobNumber.Text);

        GetFromViewStateToSaveToSession();

        Response.Redirect("~/Payroll.aspx");
    }

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.