asp.netwebforms

DataBoundControl model binding


I want to extend the ASP.NET ListView control, and I have made a class and derived from ListView. The problem is that when I am using my control and want to use the strong type model binding feature of ASP.NET I can't. What that mean is that inside the ItemTemplate of the MyListView I don't have property "Item" it says it does not exists. I can't find any information on how exactly you need to implement DataBoundControl so its supports model binding, my tests shows that you need to derived form DataBoundControl and you need to inherit INamingContainer too otherwise its not working.

Any ideas?


Solution

  • I found the problem, I was overriding the ItemTemplate property and I needed to apply all the attributes that was in the original ListView control.