I am trying to create an application where I want a data grid view to display the data depending on the date that the user selects in the combo box i.e.cmbDate according to my application. The cmbDate displays the available dates in the database. Below is my source code that I have written but on debugging the compiler gives an error of operator '==' cannot be used to compare 'System.DateTime' and 'object'. I would want that when the user clicks the load button it loads data for the date or month chosen.
namespace linqToSql_trial
{
public partial class frmSample : Form
{
private userLoginDataContext dc;
public frmSample()
{
InitializeComponent();
dc = new userLoginDataContext();
}
private void LoadDate()
{
cmbDate.DataSource = dc.flights.Select(x=>x.date);
cmbDate.DisplayMember = "date";
cmbDate.ValueMember = "date";
}
private void frmSample_Load(object sender, EventArgs e)
{
LoadDate();
}
private void btnLoad_Click(object sender, EventArgs e)
{
this.flightsDataGridView.DataSource = dc.flights.Where (x => x.date == cmbDate.SelectedItem);
}
}
}