TextBox tb = (TextBox)e.Row.FindControl("costTB"); if (e.Row.RowType == DataControlRowType.DataRow) { tb.Attributes.Add("onfocus", "Visible(this)"); tb.Attributes.Add("onblur", "Invisible(this)");