利用Repeater 控件进行修改 删除操作

<asp:Repeater ID="rptList" runat="server" OnItemCommand="rptList_ItemCommand">
     <ItemTemplate>
         <li><span class="nmem_prolit">
             <asp:Label ID="lblName" runat="server" Text='<%#Eval("Name") %>'></asp:Label>
         </span>
             <asp:LinkButton ID="lbtnModify" runat="server" Text="&lt;img name=&quot;btnModify&quot; src=images/btnEdit.gif border=0&gt;"
                 Font-Underline="true" ForeColor="Red" CommandName="Edit" CommandArgument='<%#Eval("EP_TempID") %>'></asp:LinkButton>
             <asp:LinkButton ID="lbtnDelete" runat="server" Text="&lt;img name=&quot;btnDelete&quot; src=images/btnDelete.gif border=0&gt;"
                 Font-Underline="true" ForeColor="Red" CommandName="Delete" OnClientClick="javascript:return confirm('你确定要删除吗?');"
                 CommandArgument='<%#Eval("EP_TempID") %>'></asp:LinkButton>
         </li>
     </ItemTemplate>
 </asp:Repeater>

 

 

protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
    ViewState["mEP_TempID"] = e.CommandArgument;
 
    if (e.CommandName == "Edit")
    {
        GetProductInfo(Convert.ToInt32(ViewState["mEP_TempID"]));
    }
    if (e.CommandName == "Delete")
    {
        DeleteProductInfo(Convert.ToInt32(ViewState["mEP_TempID"]));
    }
}

你可能感兴趣的:(删除)