我想要当用户单击Panel
具有session_box
单击事件触发的类时。但是当我点击它时,什么也没有发生。当我调试代码时,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);
}