我想点击转发器中一行中的超链接,它将导航到另一个页面 请告诉我如何在ASP.net 转发器控件中使用 ItemCommand
<asp:Repeater ID="rpMeetings" runat="server" DataSourceID="odsMeetings"> <ItemTemplate>
<li class="list-group-item">
<h4><asp:HyperLink ID="HyperLink1" runat="server" DataNavigateUrlFields="MeetingID" DataNavigateUrlFormatString="Forms/Meeting.aspx?meetingID={0}"
Text='<%# Eval("Title") %>'></asp:HyperLink></h4>
<p class="pull-right">Status: <strong>'<%# Eval("Status") %>'</strong></p>
<p><strong>Date:</strong> '<%# Eval("FinalDecidedTime") %>'<strong>Time:</strong> - Organized by: '<%# Eval("Organizer") %>'</p>
</li>
</ItemTemplate>
</asp:Repeater>
答案 0 :(得分:0)
使用带有命令名和参数的链接按钮而不是超链接
来解决问题 <asp:LinkButton ID="lbtnMeetingTitle" runat="server" CommandArgument='<%# Eval("MeetingID") %>' CommandName="Open" Text='<%# Eval("Title") %>'></asp:LinkButton></h4>
并在
背后的代码中 protected void rpMeetings_ItemCommand(object source, RepeaterCommandEventArgs e)
{
Response.Redirect("~/Forms/Meeting.aspx?meetingID=" + Int32.Parse(e.CommandArgument.ToString()));
}