You just have to set the ID property of the control, then set the control to validate to the ID of the control.
Below is an example
//Declare Controls
private TextBox _txtFirstName = new TextBox();
RequiredFieldValidator _rfvFirstName = new RequiredFieldValidator();
//Add text box
this._txtFirstName.ID = “txtFirstName”;
this.Controls.Add(_txtFirstName);
//Required field validator
_rfvFirstName.Text = “* First Name is required!”;
_rfvFirstName.Display = ValidatorDisplay.Dynamic;
_rfvFirstName.ControlToValidate = _txtFirstName.ID;
_rfvFirstName.ForeColor = Color.Red;
_rfvFirstName.ValidationGroup = “adduser”;
this.Controls.Add(_rfvFirstName);