private void employeemasterdg_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { System.Collections.IList selectedUser = e.AddedItems; txtcode.Text = ((DataRowView)selectedUser[0]).Row.ItemArray[0].ToString(); txtname.Text = ((DataRowView)selectedUser[0]).Row.ItemArray[1].ToString(); } catch (Exception e1) { System.Windows.MessageBox.Show(e1.Message); } conn.Close(); SqlDataReader rd3 = null; try { System.Collections.IList selectedUser = e.AddedItems; SqlCommand cmd3 = new SqlCommand(); conn.Open(); cmd3.Connection = conn; String str3 = "Select email,branch,department from empmaster where empcode=@ccode3"; cmd3.Parameters.Add(new SqlParameter("ccode3", ((DataRowView)selectedUser[0]).Row.ItemArray[0].ToString())); cmd3.CommandText = str3; rd3 = cmd3.ExecuteReader(); while (rd3.Read()) { //HERE IS THE PROBLEM this.txtemail.Text = rd3.GetString(0); //THIS DISPLAYS this.cmbtest.Text = rd3.GetString(1); //THIS DOESN'T DISPLAY-THIS IS A COMBOBOX this.cmbdept.Text = rd3.GetString(2); //THIS ALSO DOESN'T DISPLAY System.Windows.MessageBox.Show(rd3.GetString(1)); //THIS DISPLAYS } // ... } catch { // ... } // ... }
LukmanulHakeem.T wrote:this.cmbtest.Text = rd3.GetString(1);//THIS DOESN'T DISPLAY-THIS IS A COMBOBOX this.cmbdept.Text = rd3.GetString(2);//THIS ALSO DOESN'T DISPLAY
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)