While your code can work (with a fix suggested by others), this is not a good practice. This is the classic way of ASP when you use ASP.NET - it is like driving 10 MPH with a sports car on the highway.
One good practice might be to use Repeater Control - it is still simple and much more elegant.
Now .aspx will look like this:
<asp:Repeater ID="rptPlants" runat="server"> <HeaderTemplate><ol></HeaderTemplate> <FooterTemplate></ol></FooterTemplate> <ItemTemplate> <li> <span class="folder"> <%# Container.DataItem %> </span> </li> </ItemTemplate> </asp:Repeater>
And for data binding there is such code in the Page_Load function in your code behind:
string[] arrPlants = new string[] { "Sacred Datura", "Kambroo", "Wallflower", "Beech 'Retroflexa'", "Zephyr Flower" }; rptPlants.DataSource = arrPlants; rptPlants.DataBind();
In your case, just replace arrPlants with your real array, Plants .
Feel free to ask for details or explanations. :)
source share