Hi again,
I'm having a problem accessing the ViewState object. I'm using the following
two functions - as copied from the MS docs - and state.count is zero in the first
- and the while loop in the second function never iterates:
/* ------------------------------------------------------------------ */
/* ------------------------------------------------------------------ */
public string GetViewStateLis t ()
{
StateBag state = ViewState;
string result = String.Empty;
if (state.Count > 0)
{
int upperBound = state.Count;
string[] keys = new string[upperBound];
StateItem[] values = new StateItem[upperBound];
state.Keys.Copy To(keys, 0);
state.Values.Co pyTo(values, 0);
StringBuilder options = new StringBuilder() ;
for(int i = 0; i < upperBound; i++)
{
result = result + "<br>keys:" + keys[i] + "::::values[i].Value:" +
values[i].Value;
}
return result;
}
return "[no count value]";
}
/* ------------------------------------------------------------------ */
/* ------------------------------------------------------------------ */
public string EnumerateViewSt ate()
{
Int32 ndx = 0;
string keyName, keyValue;
string result = String.Empty;
StateItem myStateItem;
IDictionaryEnum erator myDictionaryEnu merator = ViewState.GetEn umerator ();
result += "[start]> ";
while(myDiction aryEnumerator.M oveNext())
{
ndx++;
result = result + "[" + ndx.ToString() + "]";
keyName = (string)myDicti onaryEnumerator .Key;
myStateItem = (StateItem)myDi ctionaryEnumera tor.Value;
keyValue = (string)myState Item.Value;
result = result + "<br>ViewSt ate[" + keyName + "] = " + keyValue;
}
return result;
}
/* ------------------------------------------------------------------ */
/* ------------------------------------------------------------------ */
Does anyone have any ideas?
THANKS!!!
- wASP
Comment