title: Irregular jump of code while returning datatable
body: <p>Hi I have a c# code for an MDI Form such as this - </p>
  
  <pre><code>private void tlstrpmenuAppointments_Click(object sender, EventArgs e)
  {
      Appointments AppointmentsObject = new Appointments(Controller.Ulink1);
      AppointmentsObject.MdiParent = FrmMainConsole.ActiveForm;
      AppointmentsObject.Show();
  }
  </code></pre>
  
  <p>This MDI has a child form named Appointments which includes the following code - </p>
  
  <pre><code>private void Appointments_Load(object sender, EventArgs e)
      {
          cmbSearchColoumn.SelectedIndex = 0;
  
          lblDoctorName.Text =lblDoctorName.Text+" "+ dt.Rows[0].ItemArray[1].ToString() + " " + dt.Rows[0].ItemArray[2].ToString() + " " + dt.Rows[0].ItemArray[3].ToString();
  
          //Load todays Time Slots-
          DataTable temp = new DataTable();
  
          // **THE PROBLEM LIES IN THE FOLLOWING STATEMENT**
          temp = appointmentsCLObject.GetTimeSlots(docid);
         // THIS CALLS THE BAL STATED BELOW THIS CODE.
  
          cmbTimeSlotsAvailable.DisplayMember = temp.Columns[1].ToString();
          cmbTimeSlotsAvailable.ValueMember = temp.Columns[0].ToString();
          cmbTimeSlotsAvailable.DataSource = temp;
          cmbTimeSlotsAvailable.SelectedIndex = 0;
  
          //Loading Patient Lists for Consulting.
          dt1 = appointmentsCLObject.GetAppointments(DateTime.Now, Convert.ToInt16(cmbTimeSlotsAvailable.SelectedValue), docid);
          dtgridAppointments.DataSource = dt1;
      }
  </code></pre>
  
  <p>The BAL is AS Follows -</p>
  
  <pre><code>public DataTable GetTimeSlots(int Docid)
      {
          DateTime dt=new DateTime();
          dt = DateTime.Now;
          DataTable dtable= appointmentMLObject.GetTimeSlots(Docid,(int)dt.DayOfWeek);
          DataTable ReturnTable = new DataTable();
          foreach (DataRow rw in dtable.Rows)
          {
              ReturnTable.Rows.Add(rw[0].ToString(),rw[1].ToString()+" "+rw[2].ToString());
          }
  
          // **PROBLEM START**
          return ReturnTable;
      }
  </code></pre>
  
  <p>**When the return statement is called the code does not return to its calling method! (??)
  Instead it returns to the MDI which has created the object of this child form.</p>
  
  <p>It returns to the statement </p>
  
  <pre><code>AppointmentsObject.Show();
  </code></pre>
  
  <p>And shows me the form with no data in it.</p>