tags:

views:

768

answers:

1

Hi ,

I got a linq based windows project.There is a form thats saving personel's departmant , title , name surname etc..In this form there is 2 combobox item that holding title and departman objects and 1 textbox , 1 listbox.When forms loads i filled listbox with Personel Class.When listbox's selected index change event occur i wanna fill comboDepartman and comboTitle with this Personel's departman and Title information(getting this from DB).I have done this but there is a problem.When i have done this ComboBoxes showing me only this personel's departman and title info not Whole Departman and Title Informations.When i fill Combobox with Whole departmans and Titles i wanna change selectedindex to personel's departman or title.

There is a easy solution for this ?

// if DepartmanID -1 > selectedindex value than getting ArgumentOutOfRangeException so my algorithma is not working with this situation.

  if (listPersonel.SelectedItem !=null)
        {
             Personel p = (Personel)listPersonel.SelectedItem;
             txtPersonelName.Text = p.PersonelName;
             txtPersonelNo.Text = p.PersonelNo.ToString();
             cmbDepartmant.SelectedIndex = Convert.ToInt32(p.DepartmantID) - 1;
             cmbTitle.SelectedIndex = Convert.ToInt32(p.TitleID) - 1;
        }
+1  A: 
cmbDepartmant.SelectedValue = Convert.ToInt32(p.DepartmantID)
omoto