怎么样获得Repeater的删除事件
我现在想做一个后台系统,但是别人做的样式是做的一个表格,
布局什么都好了,所以就不好用GridView了,
而最后是一个删除按钮
Repeater中只有一个ItemCommand事件.........
现在我就想触发这个删除按钮的事件,但是居然没有- -
请教各位一下
------解决方案--------------------protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
int id = Convert.ToInt32(e.CommandArgument);
if (e.CommandName == "Delete")
{
}
}
或按钮 onclick中 Button btn =sender as Button ;
RepeaterItem item =btn.NamingContainer as RepeaterItem;
int index = item .ItemIndex;
------解决方案--------------------<asp:Repeater ID="Repeater1" runat="server"
onitemcommand="Repeater1_ItemCommand">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" Text="删除" CommandArgument='<%#Eval("ID") %>' CommandName="Deletes" />
</ItemTemplate>
</asp:Repeater>
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "Deletes")
{
int id = Convert.ToInt32(e.CommandArgument);
Response.Write("<script>alert('" + id + "')</script>");
}
}
------解决方案--------------------结合2楼和6楼的代码就行了!! 嘿嘿,捡点小便宜