gridView Repeater 单行记录操作触发后台事件
gridView 通过linkbuttion的click时间删除数据
<asp:TemplateField HeaderText="Operate">
<ItemStyle HorizontalAlign="Center" Width="10%" />
<ItemTemplate>
<asp:LinkButton runat="server" ID="lbtnDelete" OnClientClick="return onDelete();" OnClick="lbtn_Click" CommandArgument='<%# Eval("ID")%>'>Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
后台事件处理方法 lbtn_Click:
protected void lbtn_Click(object send, EventArgs e) { LinkButton lbtn = send as LinkButton; string argument = lbtn.CommandArgument; //利用参数执行操作
}
另外一种通过command事件操作
<asp:Repeater ID="rptOrderList" runat="server" OnItemDataBound="rptOrderList_ItemDataBound" OnItemCommand="rptOrderList_ItemCommand">
<td>
<asp:LinkButton ID="lbtnWithdraw" runat="server" CommandName='Delete' CommandArgument='<%# Eval ("ID") %>'
">Delete</asp:LinkButton>
</td>
后台事件: protected void rptOrderList_ItemCommand(object source, RepeaterCommandEventArgs e)
{}