I am currently working on an asp.net project that involves using a repeater.
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<HeaderTemplate>
<asp:label ID="lblexp" runat="server" Text="05/11/1981" Visible="false"></asp:label>
</HeaderTemplate>
<ItemTemplate>
<div id="myNest" class="grid">
<div class="imgholder">
<img src="<%# Eval("ImageAlt1")%>" />
</div>
<strong><%# Eval("ItemName")%> <bdo style="color:green;">$<%# Eval("ItemPrice")%></bdo></strong>
<p class="test"><%# Eval("ItemDescription")%></p>
<div style="color:red; font-size:small;"><asp:Label ID="lblExp" Text='<%# Bind("CreateDate") %>' runat="server" /></div>
<div class="meta"><%# Eval("Email")%></div>
</div>
</ItemTemplate>
<FooterTemplate>
<asp:label ID="lblexp" runat="server" Text="05/11/1981" Visible="false"></asp:label>
</FooterTemplate>
Additionally, I have included a JavaScript function to truncate the ItemDescription
text.
<script type="text/javascript">
var after = 5;
var html = $(".grid p.test").html();
html = html.substring(0, after) + "<span> ...</span>";
$(".grid p.test").html(html);
</script>
However, there seems to be an issue where the JavaScript cannot access the elements within the repeater. How can I resolve this issue?
Currently, the error message shown is Uncaught TypeError: Cannot read property substring of undefined