You need to check for Header RowType instead of DataRow so your code will be added to the header. Have you tried debugging your code?
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.Header)
{
}
}