Im working on WPF application, that passes a value from a listview on one page to the next page to have a combox pre selected when the page loads. But its not working.
the follow is a snippet of code within the UserControl_loaded event.
Right now the a1 and a2 are there for debugging to make sure there are some values and the right values being returned before setting the selected value / item /index neither of which work.
Should i be trying to do this under another event? can anyone help point me in the right direction.
thanks
string a1 = string.Empty; string a2 = string.Empty; DataTable dtCaseInfo = dac.getCaseInfo(caseid); if (dtCaseInfo.Rows.Count > 0) { caseName = dtCaseInfo.Rows[0]["casename"].ToString(); for( int i=0;i< cbCaseName.Items.Count ;i++){ if (cbCaseName.Items[i].Equals(caseName)) { cbCaseName.SelectedIndex = i; } } cbCaseName_SelectionChanged2(); // cbCaseName.SelectedIndex //cbCaseName.SelectedValue = caseName; //a1 = cbCaseName.SelectedValue.ToString(); //a2 = caseid.ToString(); }