0

I'm using @RenderPage passing an array:

@RenderPage("/Shared/_ScopeFormControls.cshtml", ChangeScope) 

The array is declared and set initially as:

string[,] ChangeScope = { { "True" }, { "" }, { "" } };

The receiving page deconstructs the array into variables to use in its own if statements:

string[,] ChangeScope = PageData[0];   
var isValid = ChangeScope[0,0];
var InvsOut = ChangeScope[1,0];   
var ItemsToMoveIDs = ChangeScope[2,0];

That all works fine when the page is first loaded.

I'd like to reset the content of the array inside the if (IsPost) dependent on a bunch of if statements then the Renderpage would be recalled with the new values.

Basically I'd like to use the array like a normal variable and overwrite its existing content with new content, something like:

ChangeScope = { { "True" }, { "IntoScope" }, { ItemsToMoveIDs } };

Is this possible?

Pinwheeler
  • 103
  • 1
  • 3
  • 10

2 Answers2

1

Are you really looking for something as simple as:

if (IsPost)
{
    ChangeScope = new string[,] { { "True" }, { "" }, { "" } };
}
Jim Mischel
  • 131,090
  • 20
  • 188
  • 351
  • Yes, that is essentially what I have but it does not compile. it says: only assignment, call, increment, decrement, and new object expressions can be used as a statement. – Pinwheeler Apr 18 '12 at 19:07
  • @CharlotteCopper: Then post the code that you do have and maybe we can help you figure out why you're getting an error. – Jim Mischel Apr 18 '12 at 19:44
0

Try using Array.Clear().

More information can be found on MSDN here.

wachpwnski
  • 678
  • 1
  • 5
  • 11