<asp:Repeater ID="rptAttackInfo" runat="server" EnableViewState="true"
onitemcommand="rptAttackInfo_ItemCommand">
<HeaderTemplate>
<table border="0" cellspacing="1" cellpadding="0" bgcolor="#666666" align="center"
width="100%">
<tr align="center" bgcolor="#44505C">
<td width="5%" height="20px" class="t12-bai">编号</td>
<td width="8%" class="t12-bai">机房</td>
<td width="8%" class="t12-bai">主板</td>
<td width="8%" class="t12-bai">CPU</td>
<td width="8%" class="t12-bai">内存</td>
<td width="8%" class="t12-bai">硬盘</td>
<td width="8%" class="t12-bai">操作</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr align="center" bgcolor="#FFFFFF">
<!-- <td width="5%" class="t12hei"><%# Container.ItemIndex+1 %></td>-->
<td width="5%" class="t12hei"><%#Eval("ID") %></td>
<td width="8%" class="t12hei"><%#Eval("Roomname")%></td>
<td width="8%" class="t12hei"><%#Eval("Zhuban")%></td>
<td width="8%" class="t12hei"><%# Eval("Cpu")%></td>
<td width="8%" class="t12hei"><%#Eval("Neicun")%></td>
<td width="8%" class="t12hei"><%#Eval("Yingpan")%></td>
<td width="8%" class="t12hei">
<asp:LinkButton runat="server" ID="lbtEdit" CommandArgument='<%#Eval("ID")%>'
CommandName="Edit" Text="编辑"></asp:LinkButton>
<asp:LinkButton runat="server" ID="lbtDelete" CommandArgument='<%#Eval("ID")%>'
CommandName='<%# Eval("ID") %>' OnCommand="BtnDel_Click" Text="删除"></asp:LinkButton>
</td>
</tr>
</ItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:Repeater>
//删除方法
public void BtnDel_Click(object sender, CommandEventArgs e)
{
int ID = Convert.ToInt32(e.CommandName); //得到ID
int no = aInfoDal.Delete(ID); //执行删除操作,返回一个值
if (no == 1)
{
ScriptUtils.Alert("删除成功!", this.Page);
RPTPagerBind(1, 10); //重新绑定数据
}
else
{
ScriptUtils.Alert("删除失败!", this.Page);
RPTPagerBind(1, 10);//重新绑定数据
}
}
Repeater的使用
最新推荐文章于 2018-04-29 08:11:11 发布