mark jones

mark jones

  • NA
  • 31
  • 0

Trying to retrieve objects in Collection Array List

Apr 25 2006 6:44 AM

Can anyone give me any advice on the following.

Am trying to create code that shows the correct set of details when the Id number is entered.  When I access the collectioon arrayList (REGList), the same set of details are always displayed.  I cant seem to display the details in the collection arraylist for the relevant Id number.  I tried using a foreach loop but this still doesnt work.  The click event handler code am using is show below.


 private void btnSearch_Click(object sender, System.EventArgs e)
{    
  string Id = txtStudID.Text;
  if(txtStudID.Text == "")
   MessageBox.Show("Please enter the 5 digit Student ID number and try again");
foreach(object o in RegList)
  {
            int Item = 0;
   int count = 0;
   count++;
   
   if(o.GetType() == typeof(string))
   {
    if(o.ToString() == Id)
    {
     Item = count;
                   
     
     txtFirstnm.Text = RegList[Item + 1].ToString();
     txtLastnm.Text = RegList[Item + 2].ToString();
     txtAddress.Text = RegList[Item + 3].ToString();
     txtCity.Text = RegList[Item + 4].ToString();
     txtCourse.Text = RegList[Item + 5].ToString();
     txtEmail.Text = RegList[Item + 6].ToString();
     txtPhone.Text = RegList[Item + 7].ToString();
     txtComment.Text = RegList[Item + 8].ToString();

     

     
    } 
    
   }

   }
  } 

Thanks for any help


Answers (3)