D
Dave
Hi all,
I have...
using System.Collections;
namespace MyApp.Templates
{
public class MyPage : System.Web.UI.Page
{
ArrayList MyArray = new ArrayList();
int MyPointer;
private void FillArray_Click(object sender,
EventArgs e)
{
foreach (DataGridItem i in MyGrid.Items)
{
CheckBox cbSelectRows = (CheckBox)
i.FindControl("cbSelect");
if (cbSelectRows.Checked)
{
MyArray.Add(((Label) i.FindControl
("DFESLabel")).Text.ToString());
Trace.Warn(((Label) i.FindControl
("DFESLabel")).Text.ToString());
}
}
MyPointer = 0;
Response.Write (MyArray[MyPointer].ToString
());
}
private void NextButton_Click(object sender,
EventArgs e)
{
Trace.Warn("ArrayCount",
MyArray.Count.ToString());
MyPointer ++;
Trace.Warn(MyPointer.ToString());
Response.Write(MyArray MyPointer].ToString());
}
}
}
Notice my arraylist is defined outside of any functions
or events. This is to make it useable in any of the
functions.
When I do FillArray_Click, the array fills up correctly.
If however, once I have filled the arraylist, then click
NextButton, the arraylist appears to be empty. How come?
I have already filled it, it is a global arraylist, so to
me, it should remain filled.
This is C# in ASP.NET.
Thanks for any help.
Regards,
Dave Colliver.
http://www.BlackpoolFOCUS.com
I have...
using System.Collections;
namespace MyApp.Templates
{
public class MyPage : System.Web.UI.Page
{
ArrayList MyArray = new ArrayList();
int MyPointer;
private void FillArray_Click(object sender,
EventArgs e)
{
foreach (DataGridItem i in MyGrid.Items)
{
CheckBox cbSelectRows = (CheckBox)
i.FindControl("cbSelect");
if (cbSelectRows.Checked)
{
MyArray.Add(((Label) i.FindControl
("DFESLabel")).Text.ToString());
Trace.Warn(((Label) i.FindControl
("DFESLabel")).Text.ToString());
}
}
MyPointer = 0;
Response.Write (MyArray[MyPointer].ToString
());
}
private void NextButton_Click(object sender,
EventArgs e)
{
Trace.Warn("ArrayCount",
MyArray.Count.ToString());
MyPointer ++;
Trace.Warn(MyPointer.ToString());
Response.Write(MyArray MyPointer].ToString());
}
}
}
Notice my arraylist is defined outside of any functions
or events. This is to make it useable in any of the
functions.
When I do FillArray_Click, the array fills up correctly.
If however, once I have filled the arraylist, then click
NextButton, the arraylist appears to be empty. How come?
I have already filled it, it is a global arraylist, so to
me, it should remain filled.
This is C# in ASP.NET.
Thanks for any help.
Regards,
Dave Colliver.
http://www.BlackpoolFOCUS.com