public void DataBindGrid() { AdultPerson _adultPerson = new AdultPerson(); List <AdultPersonModel> lstPerson = _adultPerson.GetAllData(); //DataTable dt = new DataTable(); //Gv_ListOfPerson.DataSource = lstPerson; gvUsers.DataSource = lstPerson; }
private void btn_Search_Click(object sender, EventArgs e) { //AdultPerson personBLL = new AdultPerson(); //AdultPersonModel person = personBLL.GetDataById(int.Parse(cmbx_search.SelectedValue.ToString())); //txt_fname.Text = person.FirstName + "" + person.LastName; //txt_age.Text = person.Age.ToString(); //txt_street.Text = person.Street; //txt_address.Text = person.Address; //txt_dob.Text = person.DOB.ToString(); //txt_amount.Text = person.Amount.ToString(); AdultPerson adPerson = new AdultPerson(); List <AdultPersonModel> _person = adPerson.GetAllData(); List <AdultPersonModel> Selectedperson = new List <AdultPersonModel>(); var _selectedType = cmbox_type.SelectedItem.ToString(); switch (_selectedType) { case "Name": { Selectedperson = new List <AdultPersonModel>(); foreach (var data in _person) { if ((txt_search.Text == data.FirstName + " " + data.LastName) || (txt_search.Text == data.FirstName) || (txt_search.Text == data.LastName)) { Selectedperson.Add(data); } } break; } case "DOB": { Selectedperson = new List <AdultPersonModel>(); foreach (var data in _person) { if (txt_search.Text == data.DOB.ToShortDateString()) { Selectedperson.Add(data); } } break; } case "Age": { Selectedperson = new List <AdultPersonModel>(); foreach (var data in _person) { if (txt_search.Text == data.Age.ToString()) { Selectedperson.Add(data); } } break; } case "Amount": { Selectedperson = new List <AdultPersonModel>(); foreach (var data in _person) { if (txt_search.Text == data.Amount.ToString()) { Selectedperson.Add(data); } } break; } case "Street": { Selectedperson = new List <AdultPersonModel>(); foreach (var data in _person) { if (txt_search.Text == data.Street.ToString()) { Selectedperson.Add(data); } } break; } default: { break; } } gv_dataview.DataSource = Selectedperson; gv_dataview.Columns["Id"].Visible = false; }