I don't usually work with these types of controls, so I could be completely on the wrong track here..
The end goal is to have a dataset of records with ProductTitle, ProductURL and ProductDescription. Then have those records displayed in a 3 column format, with additional rows if needed. For example:
records 1, 2, 3, 4, 5 ,6 and 7 should show
1 - 2 - 3
4 - 5 - 6
7
The error I'm getting is
System.Web.HttpException: DataBinding: 'System.Web.UI.WebControls.ListItem' does not contain a property with the name 'ProductTitle'.
The Front-End side:
<div>
<asp:ListView ID="ListView1" runat="server" GroupItemCount="3" OnLoad="ListView1_Load">
<LayoutTemplate>
<table>
<tr>
<td>
<table border="0" cellpadding="5">
<asp:PlaceHolder runat="server" ID="groupPlaceHolder"></asp:PlaceHolder>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
</tr>
</GroupTemplate>
<ItemTemplate>
<td>
<div>
<div><%#Eval("ProductTitle")%></div>
<img alt="Test Image" src="<%#Eval("ProductURL")%>" />
<div><%# Eval("ProductDescription")%></div>
</div>
</td>
</ItemTemplate>
</asp:ListView>
</div>
I've got my Code-Behind:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub ListView1_Load(sender As Object, e As EventArgs)
Dim myPaaams As ArrayList = New ArrayList
myPaaams.Add(New ListItem("ProductTitle", "Adams Test"))
myPaaams.Add(New ListItem("ProductURL", "Adams Test"))
myPaaams.Add(New ListItem("ProductDescription", "Adams Test"))
ListView1.DataSource = myPaaams
ListView1.DataBind()
End Sub
I've also tried the following code for my ListView Load event, but this fails with the same error.
Protected Sub ListView1_Load(sender As Object, e As EventArgs)
Dim myParams As ArrayList = New ArrayList
Dim variable As New Dictionary(Of String, String) From {{"ProductTitle", "Adams Test"}, _
{"ProductURL", "value2"}, _
{"ProductDescription", "value2"}}
myParams.Add(variable)
ListView1.DataSource = myParams
ListView1.DataBind()
End Sub