protected void btnSearch0_Click(object sender, EventArgs e) { if (rbSelect.SelectedIndex == 0) { using (ClubDBEntities club = new ClubDBEntities()) { DateTime date = Convert.ToDateTime(tbDate.Text, cul); result = club.getInvoice(date); GridView1.DataSource = result; GridView1.DataBind(); } } else { if (rbSelect.SelectedIndex == 1) { var id = Convert.ToInt32(tbDate.Text); using (ClubDBEntities club = new ClubDBEntities()) { result = club.getInvoice(id); GridView1.DataSource = result; GridView1.DataBind(); } } if (rbSelect.SelectedIndex == 2) { using (ClubDBEntities club = new ClubDBEntities()) { result = club.getInvoice(tbDate.Text); GridView1.DataSource = result; GridView1.DataBind(); } } } }