How do i use an array of HtmlGenericControl. This is how i have tried to use.
HtmlGenericControl objUl = new HtmlGenericControl(“ul”);
HtmlGenericControl objLi = new HtmlGenericControl[5](“li”);
objUl.ID = “nav”;
objLi[0].InnerHtml = “First element”;
objLi[1].InnerHtml = “Second Element”;
objUl.Controls.Add(objLi[0]);
objUl.Controls.Add(objLi[1]);
mainDiv.Controls.Add(objUl);
where mainDiv is a server
control. It is giving following error
Cannot apply indexing with [] to an expression of type ‘System.Web.UI.HtmlControls.HtmlGenericControl’
Is it correct approach to build html body with an array of HtmlGenericControl? if yes then how do i use it . If no then whjat should be the approach….?please help