private void GetFactoryList() { try { string Ocode = Convert.ToString(((SessionUser)Session["SessionUser"]).OCode); string F_Name = txtS_FactoryName.Text; if (txtS_FactoryName.Text != "") { List <LC_Factory> _FactoryLN = _factorybLL.LoadFactoryListBySName(Ocode, F_Name); grdFactory1.DataSource = _FactoryLN; grdFactory1.DataBind(); } else { List <LC_Factory> _FactoryL = _factorybLL.LoadFactoryList(Ocode); grdFactory1.DataSource = _FactoryL; grdFactory1.DataBind(); } } catch (Exception ex) { throw ex; } }
private void GetFactoryList() { try { if (txtSearch.Text != "") { string Ocode = Convert.ToString(((SessionUser)Session["SessionUser"]).OCode); string name = txtSearch.Text; List <LC_Factory> _FactoryL = _factorybLL.LoadFactoryListByName(name); if (_FactoryL.Count > 0) { grdFactory2.DataSource = _FactoryL; grdFactory2.DataBind(); } else { var obj = new List <LC_Factory>(); obj.Add(new LC_Factory()); // Bind the DataTable which contain a blank row to the GridView grdFactory2.DataSource = obj; grdFactory2.DataBind(); int columnsCount = grdFactory2.Columns.Count; grdFactory2.Rows[0].Cells.Clear(); // clear all the cells in the row grdFactory2.Rows[0].Cells.Add(new TableCell()); //add a new blank cell grdFactory2.Rows[0].Cells[0].ColumnSpan = columnsCount; //set the column span to the new added cell grdFactory2.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; grdFactory2.Rows[0].Cells[0].ForeColor = System.Drawing.Color.Red; grdFactory2.Rows[0].Cells[0].Font.Bold = true; //set No Results found to the new added cell grdFactory2.Rows[0].Cells[0].Text = "NO RECORDS FOUND!"; } } else { string Ocode = Convert.ToString(((SessionUser)Session["SessionUser"]).OCode); List <LC_Factory> _FactoryL = _factorybLL.LoadFactoryList(Ocode); if (_FactoryL.Count > 0) { grdFactory2.DataSource = _FactoryL; grdFactory2.DataBind(); } else { var obj = new List <LC_Factory>(); obj.Add(new LC_Factory()); // Bind the DataTable which contain a blank row to the GridView grdFactory2.DataSource = obj; grdFactory2.DataBind(); int columnsCount = grdFactory2.Columns.Count; grdFactory2.Rows[0].Cells.Clear(); // clear all the cells in the row grdFactory2.Rows[0].Cells.Add(new TableCell()); //add a new blank cell grdFactory2.Rows[0].Cells[0].ColumnSpan = columnsCount; //set the column span to the new added cell grdFactory2.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; grdFactory2.Rows[0].Cells[0].ForeColor = System.Drawing.Color.Red; grdFactory2.Rows[0].Cells[0].Font.Bold = true; //set No Results found to the new added cell grdFactory2.Rows[0].Cells[0].Text = "NO RECORDS FOUND!"; } } } catch (Exception ex) { throw ex; } }