public void grdContingency_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        Whitfieldcore _wc = new Whitfieldcore();
        String DetailId = "";

        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            DetailId = grdContingency.DataKeys[Convert.ToInt32(e.Item.ItemIndex)].ToString();
            ((Label)(e.Item.FindControl("lblTotCost"))).Text = (Convert.ToDecimal(((Label)(e.Item.FindControl("lblqty"))).Text) * Convert.ToDecimal(((Label)(e.Item.FindControl("lblCost"))).Text.Trim())).ToString("00.00");
            //Totalprice += Convert.ToDecimal(((Label)(e.Item.FindControl("lblCost"))).Text.Trim());
            Grandprice += Convert.ToDecimal(((Label)(e.Item.FindControl("lblTotCost"))).Text.Trim());

        }
        else if (e.Item.ItemType == ListItemType.Footer)
        {
            txtTotCont.Text = Math.Floor(Grandprice).ToString();
            _wc.UpdateContengency(ViewState["EstNum"].ToString(), Convert.ToInt32(Math.Floor(Grandprice).ToString().Trim()));
            e.Item.Cells[2].Text = "Total:";
            e.Item.Cells[2].ForeColor = System.Drawing.Color.Green;
            e.Item.Cells[2].Font.Bold = true;
            e.Item.Cells[2].HorizontalAlign = HorizontalAlign.Right;
            //e.Item.Cells[3].Text = TotalPrice.ToString("00.00");
            //e.Item.Cells[3].ForeColor = System.Drawing.Color.Green;
            //e.Item.Cells[3].Font.Bold = true;
            //e.Item.Cells[3].HorizontalAlign = HorizontalAlign.Right;
            e.Item.Cells[5].Text = Grandprice.ToString("00.00");
            e.Item.Cells[5].ForeColor = System.Drawing.Color.Green;
            e.Item.Cells[5].Font.Bold = true;
            e.Item.Cells[5].HorizontalAlign = HorizontalAlign.Right;

        }
    }
 protected void btncon_Click(object sender, EventArgs e)
 {
     Whitfieldcore _wc = new Whitfieldcore();
     if (Page.IsValid)
     {
         _wc.UpdateContengency(ViewState["EstNum"].ToString(), Convert.ToInt32(txtTotCont.Text.Trim()));
     }
     Server.Transfer("whitfield_estimation.aspx?EstNum=" + ViewState["EstNum"].ToString());
 }