Changing the worksheet

I have an excel file with 5 worksheets. I have a few custom command buttons (next, prev etc.). On clicking the buttons I need to change the activeSheetIndex. With my code below, the page_load gets executed before the customCommand. How can I call the pageLoad after the custom command is executed?

static int activePage = 1;

protected void Page_Load(object sender, EventArgs e) {

GridWeb1.WebWorksheets.ActiveSheetIndex = activePage;

}

protected void GridWeb1_CustomCommand(object sender, string command) {

if (command.Equals("Start")) {

activePage = 1;

}

else if (command.Equals("Prev")) {

activePage--;

}

else if (command.Equals("Next") ) {

activePage++;

}

}

Thanks.

Hi,

I think you may add a line related different custom command buttons in your code.

E.g,

protected void GridWeb1_CustomCommand(object sender, string command) {

if (command.Equals("Start")) {

activePage = 1;

GridWeb1.WebWorksheets.ActiveSheetIndex = activePage;

}

else if (command.Equals("Prev")) {

activePage--;

GridWeb1.WebWorksheets.ActiveSheetIndex = activePage;

}

else if (command.Equals("Next") ) {

activePage++;

GridWeb1.WebWorksheets.ActiveSheetIndex = activePage;

}

}

Thank you.

I tried the exact same code before . Didn't work. For some other reason I changed the XHTML property to false and now it works. Thanks.