Why do this not work

TYPE
  TForm2 = CLASS(TWebForm)
    WebButton1: TWebButton;
    XDataWebConnection1: TXDataWebConnection;
    XDataWebDataSet1: TXDataWebDataSet;
    PROCEDURE XDataWebDataSet1AfterApplyUpdates(Sender: TDataSet; Info: TResolveResults);
    PROCEDURE XDataWebDataSet1AfterClose(Dataset: TDataSet);
    PROCEDURE XDataWebDataSet1AfterOpen(Dataset: TDataSet);
    procedure WebButton1Click(Sender: TObject);
  PRIVATE
    { Private declarations }
    whatsNext: INTEGER;
    PROCEDURE DoFirst;
    PROCEDURE DoNext;
  PUBLIC
    { Public declarations }
  END;

VAR
  Form2: TForm2;

IMPLEMENTATION

{$R *.dfm}

CONST
  C_DoFirst = 1;
  C_DoNext  = 2;

PROCEDURE TForm2.DoFirst;
BEGIN
  whatsNext := C_DoNext;
  XDataWebDataSet1.ApplyUpdates;
// I do com her and whatsnext is set to C_DoNext
// but I do not come to XDataWebDataSet1AfterApplyUpdates
// and because of that never come to  C_DoNext in XDataWebDataSet1AfterOpen
END;

PROCEDURE TForm2.DoNext;
BEGIN
  //
END;

procedure TForm2.WebButton1Click(Sender: TObject);
begin
whatsNext := C_DoFirst;
XDataWebDataSet1.Load;
end;
//Pressing he button works fine

PROCEDURE TForm2.XDataWebDataSet1AfterApplyUpdates(Sender: TDataSet; Info: TResolveResults);
BEGIN
  XDataWebDataSet1.Close;
END;

PROCEDURE TForm2.XDataWebDataSet1AfterClose(Dataset: TDataSet);
BEGIN
  XDataWebDataSet1.Load;
END;

PROCEDURE TForm2.XDataWebDataSet1AfterOpen(Dataset: TDataSet);
BEGIN
  CASE whatsNext OF
    C_DoFirst:
      BEGIN
        DoFirst;
// coming here after pressing the button works fine
      END;
    C_DoNext:
      BEGIN
        DoNext;
      END;

  END;
END;

Sorry, I don't know what you mean here.
Can you please be more clear about what "does not work"?

In DoFirst I set whatsNext to C_DoNext
After that I do XDataWebDataSet1.ApplyUpdates;
I think this should lead me To XDataWebDataSet1AfterApplyUpdates
But I never come there so there is no "close" no "load" and no doafteropen

Do you actually have updated to be applied? If there are no pending updates, AfterApplyUpdates event is not called.