日期:2014-05-18  浏览次数:20418 次

repeater中删除怎么弹出提醒
删除代码如下:
VB code
Protected Sub Repeater2_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) 
        Dim id As String
        Dim i As Integer
        id = e.CommandArgument.ToString()
        Using cn As New SqlConnection
            cn.ConnectionString = ConfigurationManager.ConnectionStrings("APSS_SqlConn").ConnectionString
            cn.Open()
            Dim sql As String
            If e.CommandName = "delete" Then
                sql = String.Concat("update tb_po2 set status='X', last_updated_time=getdate(),last_updated_by='", Session("currentuserid"), "'where poid='", id, "'")
                Dim cmd As New SqlCommand(sql, cn)
                i = cmd.ExecuteNonQuery()
                If i > 0 Then
                    Response.Redirect("po_list.aspx")
                End If
            End If
            If e.CommandName = "NC" Then
                sql = String.Concat("update tb_po2 set status='N', last_updated_time=getdate(),last_updated_by='", Session("currentuserid"), "'where poid='", id, "'")
                Dim cmd As New SqlCommand(sql, cn)
                i = cmd.ExecuteNonQuery()
                If i > 0 Then
                    Response.Redirect("po_list.aspx")
                End If
            End If
        End Using
    End Sub

代码vb的
删除已经实现,我想知道itemcommand事件删除怎么添加弹出提醒

------解决方案--------------------
在前台的html做文章。如添加

<asp:Button CommandName='<%# Eval("ID") %>' runat="server" Text="Delete" ID="btnDel" OnCommand="btnDel_Click" OnClientClick="return confirm('Are you sure you want to delete this information?')"/>

然后,在.cs文件里头的btnDel_Click()这个事件中写删除代码:

得到它的ID值: int id = Convert.ToInt32(e.CommandName);
------解决方案--------------------
<asp:Button CommandName=' <%# Eval("ID") %>' runat="server" Text="Delete" ID="btnDel" OnCommand="btnDel_Click" OnClientClick="return confirm('Are you sure you want to delete this information?')"/> 

------解决方案--------------------
在按钮中添加这个事件就可以。
OnClientClick="JavaScript:return confirm('确定删除?')"