protected void btnDeleteRow_Click(object sender, EventArgs e)
 {
     try
     {
         DTSpareReqComplt = (DataTable)ViewState["DataTableSpareReqComplt"];
         GridViewRow gvrow = (GridViewRow)(((Control)sender).NamingContainer);
         if (DTSpareReqComplt.Rows.Count > 0)
         {
             DTSpareReqComplt.Rows[gvrow.RowIndex].Delete();
             DTSpareReqComplt.AcceptChanges();
             ViewState["DataTableSpareReqComplt"] = DTSpareReqComplt;
             DTSpareReqComplt = (DataTable)ViewState["DataTableSpareReqComplt"];
             GvSpareReqComplaint.DataSource = DTSpareReqComplt;
             GvSpareReqComplaint.DataBind();
             ////for (int i = 0; i < GvSpareReqComplaint.Rows.Count; i++)
             ////{
             ////    if (DTSpareReqComplt.Rows[i]["Proposed_Qty"].ToString() != "")
             ////    {
             ////        GvSpareReqComplaint.Rows[i].Cells[0].Enabled = false;
             ////        GvSpareReqComplaint.Rows[i].Cells[1].Enabled = false;
             ////        GvSpareReqComplaint.Rows[i].Cells[2].Enabled = false;
             ////        GvSpareReqComplaint.Rows[i].Cells[3].Enabled = false;
             ////        GvSpareReqComplaint.Rows[i].Cells[4].Enabled = false;
             ////        GvSpareReqComplaint.Rows[i].Cells[5].Enabled = false;
             ////        GvSpareReqComplaint.Rows[i].Cells[6].Enabled = true;
             ////    }
             ////    else
             ////    {
             ////        GvSpareReqComplaint.Rows[i].Cells[0].Enabled = true;
             ////        GvSpareReqComplaint.Rows[i].Cells[1].Enabled = true;
             ////        GvSpareReqComplaint.Rows[i].Cells[2].Enabled = true;
             ////        GvSpareReqComplaint.Rows[i].Cells[3].Enabled = true;
             ////        GvSpareReqComplaint.Rows[i].Cells[4].Enabled = true;
             ////        GvSpareReqComplaint.Rows[i].Cells[5].Enabled = true;
             ////        GvSpareReqComplaint.Rows[i].Cells[6].Enabled = true;
             ////    }
             ////}
         }
         else
         {
             lblMessage.ForeColor = System.Drawing.Color.Red;
             lblMessage.Text      = "Currently no row exists to delete!";
         }
     }
     catch (Exception ex)
     {
         SIMSCommonClass.WriteErrorErrFile(Request.RawUrl.ToString(), ex.StackTrace.ToString() + "-->" + ex.Message.ToString());
     }
 }
    public void Fn_Add(bool flag)
    {
        try
        {
            GvSpareReqComplaint.Visible = true;
            GvSpareReqComplaint.Enabled = true;
            if (hdnDivSNo.Value == "23" & DTSpareReqComplt != null) // for Applinces only
            {
                if (DTSpareReqComplt.Rows.Count == 3)
                {
                    lblMessage.Text = "maximum 3 spares can be added for Appliances.";
                }
                else
                {
                    DTSpareReqComplt = Fn_AddNewRow();
                    GvSpareReqComplaint.DataSource = DTSpareReqComplt;
                    GvSpareReqComplaint.DataBind();
                }
            }
            else
            {
                DTSpareReqComplt = Fn_AddNewRow();
                GvSpareReqComplaint.DataSource = DTSpareReqComplt;
                GvSpareReqComplaint.DataBind();
            }

            if (flag) // BP 28 oct 12
            {
                DTSpareReqComplt.Rows.RemoveAt(DTSpareReqComplt.Rows.Count - 1);
                GvSpareReqComplaint.DataSource = DTSpareReqComplt;
                GvSpareReqComplaint.DataBind();
            }
        }
        catch (Exception ex)
        {
            SIMSCommonClass.WriteErrorErrFile(Request.RawUrl.ToString(), ex.StackTrace.ToString() + "-->" + ex.Message.ToString());
        }
    }