public override void PopulateData() { try { using (TaxiDataContext db = new TaxiDataContext()) { //grdLister.DataSource = db.stp_GetCompanyFareSettings(); var list = (from a in db.stp_GetCompanyFareSettings() orderby a.CompanyName select new { Id = a.Id, CompanyName = a.CompanyName, FromDate = a.FromDate, TillDate = a.TillDate, OperatorType = a.OperatorType, ActionType = a.ActionType, Amount = a.Amount, }).ToList(); grdLister.DataSource = list; grdLister.Columns["Id"].IsVisible = false; grdLister.Columns["CompanyName"].HeaderText = "Company"; grdLister.Columns["OperatorType"].HeaderText = "Action"; grdLister.Columns["ActionType"].HeaderText = ""; grdLister.Columns["FromDate"].HeaderText = "From Date"; grdLister.Columns["TillDate"].HeaderText = "Till Date"; grdLister.Columns["Amount"].Width = 120; grdLister.Columns["CompanyName"].Width = 220; grdLister.Columns["OperatorType"].Width = 140; grdLister.Columns["ActionType"].Width = 140; grdLister.Columns["FromDate"].Width = 150;; grdLister.Columns["TillDate"].Width = 150; (grdLister.Columns["FromDate"] as GridViewDateTimeColumn).FormatString = "{0:dd/MM/yyyy HH:mm}"; (grdLister.Columns["TillDate"] as GridViewDateTimeColumn).FormatString = "{0:dd/MM/yyyy HH:mm}"; if (grdLister.Columns.Contains("btnEdit") == false) { GridButton(); } } } catch (Exception ex) { } }