ItemCommand in repeater in ASP.net

2.9k Views Asked by At

I want to click on a hyperlink in a row in the repeater that will navigate me to another page pls let me know how to use ItemCommand in the ASP.net repeater control

<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> 
1

There are 1 best solutions below

0
On BEST ANSWER

the problem is solved using Link Button with command name and argument instead of Hyperlink

  <asp:LinkButton ID="lbtnMeetingTitle" runat="server" CommandArgument='<%# Eval("MeetingID") %>' CommandName="Open" Text='<%# Eval("Title") %>'></asp:LinkButton></h4>

and in the code behind

    protected void rpMeetings_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    Response.Redirect("~/Forms/Meeting.aspx?meetingID=" + Int32.Parse(e.CommandArgument.ToString()));
}