void BindGridEmployee(string employeeID) { try { string OCODE = ((SessionUser)Session["SessionUser"]).OCode; var emp = objEmp_BLL.GetCurrent_Employees(OCODE).ToList(); using (var _context = new ERPSSLHBEntities()) { var query = (from hl in _context.HRM_EMPLOYEE_DOCUMENTS where hl.OCODE == OCODE && hl.EID == employeeID select hl).OrderByDescending(hl => hl.FILE_ID).ToList(); var list = query.ToList(); if (list.Count() > 0) { grd_File.DataSource = list; grd_File.DataBind(); } else { var obj = new List <HRM_EMPLOYEE_DOCUMENTS>(); obj.Add(new HRM_EMPLOYEE_DOCUMENTS()); // Bind the DataTable which contain a blank row to the GridView grd_File.DataSource = obj; grd_File.DataBind(); int columnsCount = grd_File.Columns.Count; grd_File.Rows[0].Cells.Clear(); // clear all the cells in the row grd_File.Rows[0].Cells.Add(new TableCell()); //add a new blank cell grd_File.Rows[0].Cells[0].ColumnSpan = columnsCount; //set the column span to the new added cell grd_File.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; grd_File.Rows[0].Cells[0].ForeColor = System.Drawing.Color.Red; grd_File.Rows[0].Cells[0].Font.Bold = true; //set No Results found to the new added cell grd_File.Rows[0].Cells[0].Text = "NO RECORDS FOUND!"; } } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true); } }