用<%%>代码块的方式循环添加的按钮如何添加事件

用<%%>代码块的方式循环添加的按钮怎么添加事件?
本帖最后由 jplx10001 于 2012-12-18 18:13:57 编辑
我的代码如下,虽然感觉怪怪的,但我实在不知道怎么写了。新手才接触网页制作,求指教:
<table width="100%" style="text-align: center; padding: 0em 4em 0em 4em">
    <tr style="font-weight: bold; background-color: #f0f0f2; border-bottom-style: groove;">
        <td style="width: 225px">放映时间</td>
        <td>影厅空位</td>
        <td>版本</td>
        <td style="width: 161px">票价</td>
        <td></td>
    </tr>
    <%for (int i = 0; i < filmShowList.Count; i++)
    { %>
        <tr>
            <td style="width: 225px"><%=filmShowList[i].FsTime%></td>
            <td><%=new entity.FSRoom().getTotalSeats(filmShowList[i].RoomId)%></td>
            <td><%=filmShowList[i].FsEditiong%></td>
            <td style="width: 161px"><%=filmShowList[i].Price%></td>
            <td><asp:ImageButton ID="bnBuy_0" runat="server" Height="28px" 
                             ImageUrl="~/bnBuy.png" OnClick="bnBuyClick" />
            <% bnBuy_0.ID = "bnBuy_" + (i + 1).ToString();
                  bnBuy_0.Click += new ImageClickEventHandler(bnBuyClick);%>
            </td>

          </tr>
<%} %>
</table>
做出来的表格长得如下图所示,但是只有第一排的按钮有效,请问我应该怎么做?
用<%%>代码块的方式循环添加的按钮如何添加事件

------解决方案--------------------
错了,前台代码里面不需要onclikc事件的
把<asp:Button ID="Button2" runat="server" Text="Button" onclick="Button1_Click" />修改成
<asp:Button ID="Button2" runat="server" Text="Button" />