我想要當用戶點擊Panel
那個類session_box
點擊事件觸發。但是當我點擊它時,什麼都沒有發生。當我調試代碼時,ItemCommand
事件甚至不會被調用!中繼器ItemCommand事件未觸發
這裏是我的代碼:
HTML:
<div id="sessions_wrapper">
<asp:Repeater ID="sessions_repeater" runat="server"
DataSourceID="SqlDataSource1"
onitemcommand="sessions_repeater_ItemCommand">
<ItemTemplate>
<asp:Panel CssClass="session_box" runat="server" data-session-id='<%# Eval("session_id") %>'>
<asp:Image CssClass="session_icon" runat="server" ImageUrl='<%# Eval("session_cover") %>' alt="" />
<div class="session_info">
<p>Title: <%# Eval("session_name") %></p>
<p>Date: <%# Eval("session_date") %></p>
<p>Photos: <%# Eval("session_photos") %></p>
</div>
</asp:Panel>
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DBCS %>"
ProviderName="<%$ ConnectionStrings:DBCS.ProviderName %>"
SelectCommand="SELECT * FROM [sessions]"></asp:SqlDataSource>
</div>
C#:
protected void sessions_repeater_ItemCommand(object source, RepeaterCommandEventArgs e)
{
string sid = ((Panel)e.CommandSource).Attributes["data-session-id"];
Response.Redirect("sessions.aspx?sid=" + sid);
}