protected override void Grid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        base.Grid_RowDataBound(sender, e);
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            //if (!PAGENAME.Equals("products_ibom.aspx") && !PAGENAME.Equals("whatif_products_ibom.aspx"))
            if (true)
            {
                Button btnToClick = e.Row.Cells[0].FindControl(GridViewTemplate.BTN_INSERT) as Button;
                string tooltip    = "Double-click to add ";
                if (PAGENAME.Contains("labor"))
                {
                    tooltip += "labor";
                }
                else if (PAGENAME.Contains("equipment"))
                {
                    tooltip += "equipment";
                }
                else if (PAGENAME.Contains("oper"))
                {
                    tooltip += "operation";
                }
                else if (PAGENAME.Contains("routing"))
                {
                    tooltip += "routing";
                }
                else if (PAGENAME.Contains("product"))
                {
                    tooltip += "product";
                }
                else
                {
                    tooltip += "row";
                }
                if (btnToClick != null)
                {
                    string btnJavascript = ClientScript.GetPostBackClientHyperlink(
                        btnToClick, "");
                    for (int columnIndex = 1; columnIndex <
                         e.Row.Cells.Count; columnIndex++)
                    {
                        // Add the column index as the event argument parameter
                        string js = btnJavascript.Insert(btnJavascript.Length - 2,
                                                         columnIndex.ToString());
                        // Add this javascript to the onclick Attribute of the cell
                        //e.Row.Cells[columnIndex].Attributes["ondblclick"] = js;
                        // Add a cursor style to the cells
                        e.Row.Cells[columnIndex].Attributes["style"] +=
                            "cursor:pointer;";
                        ////e.Row.Cells[columnIndex].ToolTip = tooltip;

                        try
                        {
                            Control control = e.Row.Cells[columnIndex].FindControl(TEXT_BOX_IDS[columnIndex]);
                            if (control is TextBox)
                            {
                                (control as TextBox).Attributes.Add("onkeydown", "doFocus('" + btnToClick.ClientID + "', event);");
                            }
                            else if (control is AjaxControlToolkit.ComboBox)
                            {
                                TextBox textBox = (control as AjaxControlToolkit.ComboBox).FindControl(control.ID + "_TextBox") as TextBox;
                                if (textBox != null)
                                {
                                    textBox.Attributes.Add("onkeydown", "doFocus('" + btnToClick.ClientID + "', event);");
                                }
                            }
                        }
                        catch (Exception) { }
                    }
                }
            }
        }
    }
    protected virtual void Grid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //if (!PAGENAME.Equals("products_ibom.aspx") && !PAGENAME.Equals("whatif_products_ibom.aspx"))
            if (true)
            {
                Button btnToClick = e.Row.Cells[0].FindControl(GridViewTemplate.BTN_EDIT) as Button;
                string tooltip    = "Double-click to edit ";
                if (((e.Row.RowState & DataControlRowState.Edit) > 0))
                {
                    btnToClick = e.Row.Cells[0].FindControl(GridViewTemplate.BTN_UPDATE) as Button;
                    //tooltip = "Double-click to update ";

                    /*e.Row.Attributes["ondblclick"] = Page.ClientScript.GetPostBackClientHyperlink(grid, "Update$" + e.Row.RowIndex);
                     * e.Row.Attributes["style"] = "cursor:normal;";
                     * e.Row.ToolTip = "Double-click to update row";*/
                }
                if (PAGENAME.Contains("labor"))
                {
                    tooltip += "labor";
                }
                else if (PAGENAME.Contains("equipment"))
                {
                    tooltip += "equipment";
                }
                else if (PAGENAME.Contains("oper"))
                {
                    tooltip += "operation";
                }
                else if (PAGENAME.Contains("routing"))
                {
                    tooltip += "routing";
                }
                else if (PAGENAME.Contains("product"))
                {
                    tooltip += "product";
                }
                else
                {
                    tooltip += "row";
                }
                if (btnToClick != null)
                {
                    string btnJavascript = ClientScript.GetPostBackClientHyperlink(
                        btnToClick, "");


                    for (int columnIndex = 1; columnIndex <
                         e.Row.Cells.Count; columnIndex++)
                    {
                        if (!((e.Row.RowState & DataControlRowState.Edit) > 0))
                        {
                            // Add the column index as the event argument parameter
                            string js = btnJavascript.Insert(btnJavascript.Length - 2,
                                                             columnIndex.ToString());
                            // Add this javascript to the onclick Attribute of the cell
                            e.Row.Cells[columnIndex].Attributes["ondblclick"] = js;
                            // Add a cursor style to the cells
                            e.Row.Cells[columnIndex].Attributes["style"] +=
                                "cursor:pointer;";
                            e.Row.Cells[columnIndex].ToolTip = tooltip;
                        }



                        try
                        {
                            Control control = e.Row.Cells[columnIndex].FindControl(TEXT_BOX_IDS[columnIndex]);
                            if (control is TextBox)
                            {
                                (control as TextBox).Attributes.Add("onkeydown", "doFocus('" + btnToClick.ClientID + "', event);");
                            }
                            else if (control is AjaxControlToolkit.ComboBox)
                            {
                                TextBox textBox = (control as AjaxControlToolkit.ComboBox).FindControl(control.ID + "_TextBox") as TextBox;
                                if (textBox != null)
                                {
                                    textBox.Attributes.Add("onkeydown", "doFocus('" + btnToClick.ClientID + "', event);");
                                }
                            }
                        }
                        catch (Exception) { }
                    }

                    //e.Row.Attributes["ondblclick"] = Page.ClientScript.GetPostBackClientHyperlink(grid, "Edit$" + e.Row.RowIndex);
                    //e.Row.Attributes["style"] = "cursor:pointer";
                    //e.Row.ToolTip = "Double-click to edit row";
                }
            }
            //e.Row.Cells[1].ForeColor = ColorTranslator.FromHtml("black");
            //e.Row.Cells[1].Font.Bold = false;


            foreach (TableCell cell in e.Row.Cells)
            {
                cell.DataBind();


                try
                {
                    foreach (Control control in cell.Controls)
                    {
                        foreach (Control control2 in control.Controls)
                        {
                            if (control2 is Label)
                            {
                                Label lbl = control2 as Label;
                                lbl.CssClass = "padding";
                                double num = Double.Parse(lbl.Text);

                                cell.HorizontalAlign = HorizontalAlign.Center;
                                if (((e.Row.RowState & DataControlRowState.Edit) > 0))
                                {
                                    lbl.Enabled              = false;
                                    lbl.Attributes["style"] += "cursor:default;";
                                }

                                break;
                            }
                            else if (control2 is TextBox || control2 is AjaxControlToolkit.ComboBox || control2 is CheckBox)
                            {
                                cell.HorizontalAlign = HorizontalAlign.Center;
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
        }
    }