【发布时间】:2014-09-26 20:23:31
【问题描述】:
我正在像这样绑定到 ListView:
var authors = (from a in db.Books
where a.Author.StartsWith(letter)
group a by a.Author into g
select new{Author=g.Key}).ToList();
ListView1.DataSource = authors;
ListView1.DataBind();
当用户单击项目时,我需要使用一些查询字符串将他重定向到另一个页面。这是我的 ItemTemplate:
<ItemTemplate>
<td runat="server" onclick="window.location.href = 'CatalogAutor.aspx?text=<%#Eval("Author") %>';">
<asp:Label ID="AutorLabel" runat="server" Text='<%# Eval("Author") %>' />
</td>
</ItemTemplate>
asp:Label 中的Eval("Author") 运行良好,但为什么我在 onclick 事件中的 Eval 上收到“解析器错误:服务器标记格式不正确”?
有没有其他方法可以从点击的表格单元格中获取作者姓名?
【问题讨论】:
-
请注意,
<td>不像<asp:Label>那样是 ASP.NET Web 控件。我强烈怀疑这就是问题所在。请注意,我已经很久没有使用网络表单了。
标签: javascript c# asp.net