The cowboy in the book "Holes" by Louis Sachar is
Stanley Yelnats IV, the main character. He is called a cowboy because of the way he dresses and acts while he is at Camp Green Lake. He wears a cowboy hat and boots and carries a shovel like a cowboy would carry a lasso. This is all due to the strict and unusual rules of the camp, where the boys are forced to dig holes all day long as punishment.
Stanley's cowboy persona is a way for him to cope with the harsh conditions and find some humor in his situation. It also serves as a symbol of his transformation from a naive and unlucky kid to a resourceful and resilient individual.