Cannot add property into Class when implementing ICollection interface


P

Pinkesh

Hi All,

I have a very nice problem to be solved!!!

I am developing a Control which contains other controls and Templates
in it.

Following is the snippet of the code in .aspx file:
-------------------------------------------------------------------------------------------------------------------------------
<asp:Repeater ID="rptrMain" runat="server" DataSourceID="AssetDS">
<ItemTemplate>
<emotion:AssetView ID="AssetView1" runat="server"
TemplateIndex="1"
MyDataSource="<%# Container.DataItem %>">
<Area Index="1">
<em:Field runat="server" ID="Item" Text="Item: "
Value="Item"></em:Field>
<em:Field runat="server" ID="AssetName"
Text="Name: "
Value="Name"></em:Field>
<em:Field runat="server" ID="Category"
Text="Category: "
Value="Category"></em:Field>
</Area>
</emotion:AssetView>
</ItemTemplate>

</asp:Repeater>
-------------------------------------------------------------------------------------------------------------------------------
Code Explanation: Please find <Area Index="1>... tag in the above code.
Where <Area> tag is the collection of "FieldCollection" Class.

The "FieldCollection" Class is defined as:
public class FieldCollection : Control, ICollection
{
public FieldCollection()
{
_list = new Collection<Field>();
}

private int _index;
public int Index
{
get { return _index; }
set { _index = value; }
}
...........
...........
........... // ICollection properties implemented.
}

Now the PROBLEM IS: The .Net parser could not find the property (namely
'Index') of the <Area> tag and gives the following error generated:
-------------------------
Parser Error
Description: An error occurred during the parsing of a resource
required to service this request. Please review the following specific
parse error details and modify your source file appropriately.

Parser Error Message: Property 'Area' does not have a property named
'Index'.
---------------------------

Could anybody find the solution to this? Please let me know if you
have.

Thanks in advance.

Regards,
Pinkesh.
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top