单击gridview外部的删除按钮时,如何在删除grid视图记录之前显示确认消息? [英] How to show the confirm message before delete Grid view record when you click delete button outside the gridview?

查看:68
本文介绍了单击gridview外部的删除按钮时,如何在删除grid视图记录之前显示确认消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

gridview有单选按钮,我想在选择单选按钮后显示确认消息.


代码:


试试
{
for(int i = 0; i; grdLanguagedesc.Rows.Count; i ++)
{

RadioButton rb =(RadioButton)grdLanguagedesc.Rows [i] .FindControl(&"RowSelector& quot;);;
如果(rb.Checked == true)
{
//Page.ClientScript.RegisterStartupScript(this.GetType(),clientScript,返回Confirm(``确定要删除此记录吗?'');, true);
//ScriptManager.RegisterStartupScript(this、this.GetType()、clientScript、confirm_delete();、true);
//Page.ClientScript.RegisterStartupScript(this.GetType(),clientScript,javascript:if(!confirm(``您是否希望完成此订单?''))返回false;);
字符串msgid = grdLanguagedesc.Rows [i] .Cells [1] .Text;
DeleteRecords(msgid);
lblError.Visible = true;
返回;
其他
{
lblError.Visible = true;
lblError.Text =请在GridView中选择记录;
btnSearch.Focus();
lnkfilter.Focus();

}
}
}



< b>
当您单击gridview外部的删除按钮时,如何在删除grid视图记录之前显示确认消息?</b>

The gridview have radio button i want to show confirm message after radio button selected.


Code:


try
{
for (int i = 0; i; grdLanguagedesc.Rows.Count; i++)
{

RadioButton rb = (RadioButton)grdLanguagedesc.Rows[i].FindControl(&quot;RowSelector&quot;);
if (rb.Checked == true)
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), clientScript, return confirm(''Are you sure you want to delete this record?'');, true);
//ScriptManager.RegisterStartupScript(this, this.GetType(), clientScript, confirm_delete();, true);
//Page.ClientScript.RegisterStartupScript(this.GetType(), clientScript, javascript:if(!confirm(''Do you wish to complete this order?'')) return false;);
string msgid = grdLanguagedesc.Rows[i].Cells[1].Text;
DeleteRecords(msgid);
lblError.Visible = true;
return;
else
{
lblError.Visible = true;
lblError.Text = Please Select Record in GridView;
btnSearch.Focus();
lnkfilter.Focus();

}
}
}



<b>
How to show the confirm message before delete Grid view record when you click delete button outside the gridview?</b>

推荐答案

为按钮添加OnClientClick javascript函数和显示确认按钮并仅在用户确认后返回true.
Add OnClientClick javascript function for the button and show the confirm button and return true only if user confirmed it.


1.为Grid itemdatabound/rowdatabound事件编写一个事件处理程序.
2.在该事件处理程序内,使用FindControl方法找到每个单选按钮.
3.在单选按钮控件的属性集合中添加一个javascript函数.别忘了写"return",如下所示

1. Write an event handler for the Grid itemdatabound/rowdatabound event.
2. Inside that eventhandler, find each radio button using FindControl method.
3. add an javascript function in attributes collection of radion button control. Dont forget to write "return" as follows

RadioButton rd = FindControl...

rd.attributes.add("onclick","return ShowAlert(this.id)");


4.编写如下的javascript函数ShowAlert()


4. Write a javascript function ShowAlert() as follows

function ShowAlert()
{
   var response = Confirm("Want to proceed?")
   if(response)
   return true;
    else
   return false;
}



希望对您有帮助.



Hope it helps you.


这篇关于单击gridview外部的删除按钮时,如何在删除grid视图记录之前显示确认消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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