protected void BtnAddItem_Click(object sender, EventArgs e)
 {
     try
     {
         List <PORecordDetail> poRecordDetailsList = new List <PORecordDetail>();
         foreach (GridViewRow r in GridViewPO.Rows)
         {
             PORecordDetail poRecordDetails = new PORecordDetail();
             poRecordDetails.ItemID    = (r.FindControl("Txtitemid") as TextBox).Text;
             poRecordDetails.UOM       = PurchasingLogic.GetUOM(poRecordDetails.ItemID, DdlSli.SelectedValue);
             poRecordDetails.Quantity  = int.Parse((r.FindControl("Txtquantity") as TextBox).Text);
             poRecordDetails.UnitPrice = PurchasingLogic.GetUnitPrice(poRecordDetails.ItemID, DdlSli.SelectedValue);
             poRecordDetailsList.Add(poRecordDetails);
         }
         PORecordDetail poRecordDetailsNew = new PORecordDetail();
         poRecordDetailsList.Add(poRecordDetailsNew);
         GridViewPO.DataSource = poRecordDetailsList;
         GridViewPO.DataBind();
     }
     //In the event when a wrong Supplier was selected or Invalid Item ID is entered.
     catch (Exception)
     {
         statusMessage.Text      = "Error! Please check that the correct Supplier and ItemID has been selected.";
         statusMessage.ForeColor = System.Drawing.Color.Red;
         statusMessage.Visible   = true;
     }
 }
        protected void BindGrid()
        {
            PORecordDetail        poRecordDetails     = new PORecordDetail();
            List <PORecordDetail> poRecordDetailsList = new List <PORecordDetail>();

            poRecordDetailsList.Add(poRecordDetails);
            GridViewPO.DataSource = poRecordDetailsList;
            GridViewPO.DataBind();
        }
 protected void GridViewPO_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         List <PORecordDetail> emptyPO = new List <PORecordDetail>();
         PORecordDetail        p       = new PORecordDetail();
         emptyPO.Add(p);
         GridViewPO.DataSource = emptyPO;
         GridViewPO.DataBind();
     }
 }
        protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Label LblSn = GridViewPO.Rows[e.RowIndex].Cells[0].FindControl("LblSn") as Label;
            int   sN    = int.Parse(LblSn.Text);

            List <PORecordDetail> poRecordDetailList = new List <PORecordDetail>();

            foreach (GridViewRow r in GridViewPO.Rows)
            {
                PORecordDetail poRecordDetails = new PORecordDetail();
                poRecordDetails.ItemID    = (r.FindControl("Txtitemid") as TextBox).Text;
                poRecordDetails.Quantity  = Convert.ToInt32((r.FindControl("Txtquantity") as TextBox).Text.ToString());
                poRecordDetails.UOM       = PurchasingLogic.GetUOM(poRecordDetails.ItemID, DdlSli.SelectedValue);
                poRecordDetails.UnitPrice = (double)(PurchasingLogic.GetUnitPrice(poRecordDetails.ItemID, DdlSli.SelectedValue));
                poRecordDetailList.Add(poRecordDetails);
            }
            poRecordDetailList.RemoveAt(sN - 1);
            GridViewPO.DataSource = poRecordDetailList;
            GridViewPO.DataBind();
        }