我想从GridView.Before删除记录这个要求象&QUOT确认;确认要删除&QUOT?; [英] I want to delete record from GridView.Before to this ask for confirmation like "Are you sure to delete?"

查看:102
本文介绍了我想从GridView.Before删除记录这个要求象&QUOT确认;确认要删除&QUOT?;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从GridView.Before删除记录这一请求确认类似您确定要删除吗?

I want to delete record from GridView.Before to this ask for confirmation like "Are you sure to delete?"

我以前在GridView的命令字段,

I used command field in GridView,

<asp:CommandField HeaderText="Delete" ShowDeleteButton="True" />

我在JavaScript写了一个函数

I wrote a function in javascript

function confirm_Delete()
{
    var r = confirm("Are you sure you want to Remove this Record!");

    if (r == true)
    {
        alert("Record Deleted");
        return true;
    }
    else 
    {
        return false;
    }
}

我怎么会叫这个上删除点击。
请提示!

How I will call this on delete click. Kindly suggest !

推荐答案

您不能使用此命令字段实现的,你必须做出一个模板字段:

You can't achieve this using the command field, you have to make a template field:

<asp:TemplateField>
        <ItemTemplate>
            <asp:LinkButton ID="lbtnDelete" runat="server" CommandName="Delete" Text="Delete" 
             OnClientClick="javascript:return confirm('Are you sure you want to Remove this Record!');">
            </asp:LinkButton>
        </ItemTemplate>
    </asp:TemplateField>

这将您的行为与命令字段目前正在做同样的方式。

It will behave the same way you are doing currently with the Command Field.

这篇关于我想从GridView.Before删除记录这个要求象&QUOT确认;确认要删除&QUOT?;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆