private void LoadPrincipalList() { try { string Ocode = Convert.ToString(((SessionUser)Session["SessionUser"]).OCode); List <Com_Buyer_Setup> List = _Buyerbll.GetBuyerList(Ocode); if (List.Count > 0) { ddlPrincipalName.DataSource = List.ToList(); ddlPrincipalName.DataTextField = "PrincipalName"; ddlPrincipalName.DataValueField = "PrincipalName"; ddlPrincipalName.DataBind(); ddlPrincipalName.Items.Insert(0, new ListItem("---Select One---")); } } catch (Exception ex) { throw ex; } }
private void GetBuyerList() { try { string Ocode = Convert.ToString(((SessionUser)Session["SessionUser"]).OCode); List <Com_Buyer_Setup> BuyerList = _Buyerbll.GetBuyerList(Ocode); if (BuyerList.Count > 0) { grdBuyer.DataSource = BuyerList; grdBuyer.DataBind(); } } catch (Exception) { throw; } }
private void GetBuyerList() { try { if (txtSearch.Text != "") { string Ocode = Convert.ToString(((SessionUser)Session["SessionUser"]).OCode); string name = txtSearch.Text; List <Com_Buyer_Setup> BuyerList = _Buyerbll.GetBuyerByName(name); if (BuyerList.Count > 0) { grdBuyer.DataSource = BuyerList; grdBuyer.DataBind(); } else { var obj = new List <Com_Buyer_Setup>(); obj.Add(new Com_Buyer_Setup()); // Bind the DataTable which contain a blank row to the GridView grdBuyer.DataSource = obj; grdBuyer.DataBind(); int columnsCount = grdBuyer.Columns.Count; grdBuyer.Rows[0].Cells.Clear(); // clear all the cells in the row grdBuyer.Rows[0].Cells.Add(new TableCell()); //add a new blank cell grdBuyer.Rows[0].Cells[0].ColumnSpan = columnsCount; //set the column span to the new added cell grdBuyer.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; grdBuyer.Rows[0].Cells[0].ForeColor = System.Drawing.Color.Red; grdBuyer.Rows[0].Cells[0].Font.Bold = true; //set No Results found to the new added cell grdBuyer.Rows[0].Cells[0].Text = "NO RECORDS FOUND!"; } } else { string Ocode = Convert.ToString(((SessionUser)Session["SessionUser"]).OCode); List <Com_Buyer_Setup> BuyerList = _Buyerbll.GetBuyerList(Ocode); if (BuyerList.Count > 0) { grdBuyer.DataSource = BuyerList; grdBuyer.DataBind(); } else { var obj = new List <Com_Buyer_Setup>(); obj.Add(new Com_Buyer_Setup()); // Bind the DataTable which contain a blank row to the GridView grdBuyer.DataSource = obj; grdBuyer.DataBind(); int columnsCount = grdBuyer.Columns.Count; grdBuyer.Rows[0].Cells.Clear(); // clear all the cells in the row grdBuyer.Rows[0].Cells.Add(new TableCell()); //add a new blank cell grdBuyer.Rows[0].Cells[0].ColumnSpan = columnsCount; //set the column span to the new added cell grdBuyer.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center; grdBuyer.Rows[0].Cells[0].ForeColor = System.Drawing.Color.Red; grdBuyer.Rows[0].Cells[0].Font.Bold = true; //set No Results found to the new added cell grdBuyer.Rows[0].Cells[0].Text = "NO RECORDS FOUND!"; } } } catch (Exception) { throw; } }