private void button1_Click(object sender, EventArgs e)
{
resultBindingSource1.DataSource = from result in ds.Results where result.REGISTRATION_NUMBER == textBox1.Text && result.EXAM_YR == comboBox1.SelectedItem select result;
}
The above code works perfectly when i click button1 to to filter the datasource.
Please i need an error message box to pop up if the textbox and combobox are empty or the values are incorrect
Thanks
Loading


Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 3, 2013, 9:32 PM EDT
private void button1_Click(object sender, EventArgs e)
{
if(textBox1.Text!=String.Empty && comboBox1.SelectedText!=String.Empty)
{
resultBindingSource1.DataSource = from result in ds.Results where result.REGISTRATION_NUMBER == textBox1.Text && result.EXAM_YR == comboBox1.SelectedItem select result;
}
else
{
MessageBox.Show("Enter details");
}
}
Christian NwambaRank #8,005 · 230 reputationPosted Sep 3, 2013, 11:47 PM EDT
Thanks for your help
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 4, 2013, 1:24 AM EDT
private void button1_Click(object sender, EventArgs e)
{
if(textBox1.Text!=String.Empty && comboBox1.SelectedText!=String.Empty)
{
var res = from result in ds.Results where result.REGISTRATION_NUMBER == textBox1.Text && result.EXAM_YR == comboBox1.SelectedItem select result;
if(res!=null)
resultBindingSource1.DataSource=res;
else
MessageBox.Show("no data found");
}
else
{
MessageBox.Show("Enter details");
}
}
Christian NwambaRank #8,005 · 230 reputationPosted Sep 4, 2013, 11:49 AM EDT