I am trying to create a form where the user can view data from the database in a datagrid view. I want the user to be able to choose like the time period from which to start from in one combobox cmbDate and the period to in another combobox cmbDateTo.I have written the following code:
namespace linqToSql_trial { public partial class frmMonthlyOperatorStatistics : Form { private userLoginDataContext dc;
public frmMonthlyOperatorStatistics()
{
InitializeComponent();
dc = new userLoginDataContext();
}
private void LoadData()
{
cmbDate.DataSource = dc.dailyOperatorStatistics.Select(x=>x.date);
cmbDate.DisplayMember = "date";
cmbDate.ValueMember = "date";
}
private void LoadDateTo()
{
cmbToDate.DataSource = from to in dc.dailyOperatorStatistics
select to;
cmbToDate.DisplayMember = "date";
cmbToDate.ValueMember = "date";
}
private void btnLoad_Click(object sender, EventArgs e)
{
this.operatorStatDataGridView.DataSource = dc.dailyOperatorStatistics.Where(x => x.date >= Convert.ToDateTime(cmbDate.SelectedItem) && <= Convert.ToDateTime(cmbToDate.SelectedItem));
}
private void frmMonthlyOperatorStatistics_Load(object sender, EventArgs e)
{
LoadData();
LoadDateTo();
}
} } It is generating errors on the button clicking method via the part <= Convert.ToDateTime(cmbToDate.SelectedItem));