I m having a proble with the following code..
private
void comboBox1_Click(object sender, EventArgs e){
SpecialType = comboBox1.SelectedItem.ToString();
string sql = "select doctors.doctorname+' '+doctors.doctorlname from doctors ,SpecializationTypes ,SDT ";sql = sql + " where SpecializationTypes.SpecializationTypeID = doctors.Specilization ";
sql = sql + " and doctors.hospitalcode = SDT.hospitalcode";
sql = sql + " and SDT.hospitalname = " + "'" + textBox1.Text + "'";
sql = sql + " and SpecializationTypes.SpecializationType = " + "'" + SpecialType + "'";
SqlCommand mySqlCommand =
new SqlCommand(sql);mySqlCommand.Connection = mySqlConnection;
SqlDataAdapter adapter1 =
new SqlDataAdapter(mySqlCommand);DataSet ds1 =
new DataSet();adapter1.Fill(ds1);
listBox2.DataSource = ds1;
listBox2.DisplayMember = "doctorname";
}
what should be the displaymember property of this listbox2
as when I click on combobox it displays..
System.Data.DataViewManagerListItem TypeDescriptor in Listbox2..
Can anybody help????
Rahul GoelPosted Nov 21, 2005, 12:01 AM
Try this
It will solve your problem
private void comboBox1_Click(object sender, EventArgs e)
{
SpecialType = comboBox1.SelectedItem.ToString();
string sql = "select doctors.doctorname+' '+doctors.doctorlname from doctors ,SpecializationTypes ,SDT ";
sql = sql + " where SpecializationTypes.SpecializationTypeID = doctors.Specilization ";
sql = sql + " and doctors.hospitalcode = SDT.hospitalcode";
sql = sql + " and SDT.hospitalname = " + "'" + textBox1.Text + "'";
sql = sql + " and SpecializationTypes.SpecializationType = " + "'" + SpecialType + "'";
SqlCommand mySqlCommand = new SqlCommand(sql);
mySqlCommand.Connection = mySqlConnection;
SqlDataAdapter adapter1 = new SqlDataAdapter(mySqlCommand);
DataSet ds1 = new DataSet();
adapter1.Fill(ds1,"DoctorsList");
listBox2.DataSource = ds1.Tables[0];
listBox2.DisplayMember = "doctorname";
}
rahul