Ok ControlCollection is uncooperative
I have a section of code that I thought would work beautifully but it doesn't. It shows my control count as 2, but I have 60 radio buttons, 1 label, and an image.
I have played with the code for the past two hours and I am pretty sure I am referencing a bad page object but all the googling in the worlds seems to only confuse me more...
So with no more ado...
Code:
protected void UpdateQuestionStatusLabel(object source,EventArgs e)
{
int i=0;
int CtlCnt=0;
HttpResponse resp=this.Response;
System.Web.UI.Page currPage=this.Page;System.Web.UI.ControlCollectionctlCollection=currPage.Controls;
//System.Web.UI.Page currPage;
StringBuilder thelabel = new StringBuilder();
lblStatus.Text="Hello";
foreach(Control myCtl in currPage.Controls)
{
i++;
//lblStatus.Text="Function";
if(myCtl is System.Web.UI.WebControls.RadioButton)
{
//thelabel.Append(myCtl.ID);
}
}
//lblStatus.Text=thelabel.ToString();
CtlCnt=ctlCollection.Count;
lblStatus.Text=CtlCnt.ToString();
}
Thanks for all future help.