private async void BtnAgeWiseFillGrid_Click(object sender, RoutedEventArgs e) { MembersService members = new MembersService(); list = await members.GetMembersByAgeWise(); MemberDatagridview.ItemsSource = list.Take(numberOfRecPerPage); int count = list.Take(numberOfRecPerPage).Count(); lblPageNumber.Content = count + " of " + list.Count; TotalNoPeople totalNoPeople = new TotalNoPeople(); totalNoPeople.NoMales = list.Where(x => x.Sex == "M").Count().ToString(); totalNoPeople.NoFemales = list.Where(x => x.Sex == "F").Count().ToString(); this.DataContext = totalNoPeople; FillType = 2; }