I am using asp.net 4.5 c#. I have created a user control with the following member inside:
[Bindable(true)]
public Product item
{
get{
return _product;
}
set
{
_product = value;
}
}
I then use my control, while DataBinding a "Product" into the member above:
<script runat="server">
Product item=new Product();
</script>
<uc:productBox runat="server" item="<%#item%>"/>
While this works, Trying to bind dynamic items from a list in the following way fails:
foreach (Product item in ProductList()){%>
<uc:productBox runat="server" item="<%#item%>"/>
<%}%>
I get the following error:
The name 'item' does not exist in the current context
Why can't I bind items from a list and how can I solve this in order to work?