public override void DisplayRecord() { try { grdPostCodes.Rows.Clear(); using (TaxiDataContext db = new TaxiDataContext()) { var list = db.stp_DisplayPostCodes().ToList(); grdPostCodes.RowCount = list.Count; for (int i = 0; i < list.Count; i++) { if (list[i].PostCodeId != null) { grdPostCodes.Rows[i].Cells[COLS.Check].Value = true; } grdPostCodes.Rows[i].Cells[COLS.Id].Value = list[i].Id; grdPostCodes.Rows[i].Cells[COLS.PostCode].Value = list[i].Postcode; grdPostCodes.Rows[i].Cells[COLS.AreaName].Value = list[i].AreaName; } var selectedlist = list.Where(c => c.PostCodeId != null).ToList(); grdSelectedPostCodes.RowCount = selectedlist.Count; for (int i = 0; i < selectedlist.Count; i++) { grdSelectedPostCodes.Rows[i].Cells[COLS.Id].Value = selectedlist[i].Id; grdSelectedPostCodes.Rows[i].Cells[COLS.PostCode].Value = selectedlist[i].Postcode; grdSelectedPostCodes.Rows[i].Cells[COLS.AreaName].Value = selectedlist[i].AreaName; } } SelectedPostCodes(); grdPostCodes.CurrentRow = null; lblUpdate.Text = string.Empty; lblSelectedPostCodes.Text = "Selected PostCodes " + (grdSelectedPostCodes.Rows.Count); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }