Posted on: 12/6/2013 3:52:21 PM | Views : 827

I have a little issue.
The control "div" is out of scope when trying to add child controls it in my foreach loop.  I need to re-create that control every time i = 1.  I am pretty new to c# and this is killing me.  I thought that because I declared the control outside of the foreach, it would work.  Any suggestions?
public Control MakeGalleryGrid() { images img = new images(); List<Categories> cl = img.GetCategories(); Control c = new Control(); HtmlGenericControl div; HtmlGenericControl article; HtmlGenericControl header; HtmlGenericControl p; HtmlGenericControl h3; HyperLink hl; ImageButton ib; int i = 0; foreach (Categories cat in cl) { i++; if (i == 1) { div = new HtmlGenericControl("div"); ...

Go to the complete details ...