hi,
The JavaScript will get call if you click on the button twice. If you debug it, you will notice that the fvATSDetails_ItemCommand method will not be executed on page load. The only time the method get trigger is when you click on the button. If you want the to add the JavaScript to the Button on page-load/render. Try bind it through the DataBound event.
protected void Page_Load(object sender, EventArgs e)
{
fvATSDetails.DataBound += new EventHandler(fvATSDetails_DataBound);
}
void fvATSDetails_DataBound(object sender, EventArgs e)
{
Button btnDoc = (Button)fvATSDetails.FindControl("btnDoc");
btnDoc.Attributes.Add("onclick", "javascript:OpenFiles();");
}