0

我想单击转发器中一行中的超链接,它将导航到另一个页面请让我知道如何在 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> 
4

1 回答 1

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()));
}
于 2015-08-13T12:21:19.077 回答