private void button1_Click(object sender, EventArgs e) { localhost.Service1 service = new localhost.Service1(); bool isvalidSub; bool isvalidsubject; service.isValidSubject(cmbsubject.Text, out isvalidsubject, out isvalidSub); BindingSource source = new BindingSource(); if (isvalidsubject) { service.ShowBySubject(cmbsubject.Text); source.DataSource = service.ShowBySubject(cmbsubject.Text); dataGridView1.DataSource = source; } else { MessageBox.Show("Subject Not Registered"); } }