通过单击警告框的“确定”按钮在警报框中显示数据

编程入门 行业动态 更新时间:2024-10-25 22:30:17
本文介绍了通过单击警告框的“确定”按钮在警报框中显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在警告框中显示名称,然后在网格视图的格式中单击警告框的确定按钮,并在gridview中更新或删除属性,在另一个警告框中显示该名称及其ID。任何机构都有解决方案所以请提供

解决方案

Hello Masroor, 如果我正确理解你的问题那么请参考这 [ ^ ]文章。它显示了如何使用gridview进行INSERT / UPDATE。 现在我们假设您要通过首先显示名称来确认删除操作,然后再显示另一个显示名称和ID的确认。在这种情况下,您可以连接以下JavaScript函数。

function confirmDelete(strName,strId){ var r = confirm( 将删除 + strName); if (r == true ){r = confirm( 将删除id为 + strId + 的记录并命名为 + strName); if (r == true ) return true ; } 返回 false ; }

javascript连接将在gridview的 RowDataBound 事件中完成。因此,请从上面文章中显示的aspx文件中删除onClientClick代码。代码中的连接代码将如下所示:

protected void GridView1_OnRowDataBound( object sender,GridViewRowEventArgs e){ try { if (e.Row.RowType == DataControlRowType.DataRow){ DataRowView drEachRow =(DataRowView)e.Row 。数据项; LinkBut​​ton lbBind =(LinkBut​​ton)e.Row.FindControl( lnkRemove); lbBind.Attributes.Add( onclick, javascript:return confirmDelete(' + DataBinder.Eval(e.row.DataItem,) ContactName)+ ',' + DataBinder.Eval(e.row.DataItem, CustomerID)+ ');); } } catch (例外objExp){ // 处理异常 } }

问候,

I want to display name in alert box and then display that name with its id in another alert box by clicking ok button of alert box in the format of grid view with having property to update or delete within gridview. Any body have a solution so please provide

解决方案

Hello Masroor, If I understand your question correctly then please refer to this[^] article. It shows how to do INSERT/UPDATE using a gridview. Now lets assume that you want to confirm the delete operation by first displaying the name, followed by another confirm showing the name and the id. In that case you can hook up following JavaScript function.

function confirmDelete(strName, strId) { var r = confirm("Will delete " + strName); if (r == true) { r = confirm("Will delete record having id " + strId + " and name " + strName); if (r == true) return true; } return false; }

The javascript wiring will be done in RowDataBound event of the gridview. So do remove the onClientClick code from the aspx file shown in above article. The wiring up code in your code behind will be something like one shown below.

protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e ) { try { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView drEachRow = (DataRowView) e.Row.DataItem; LinkButton lbBind= (LinkButton )e.Row.FindControl("lnkRemove"); lbBind.Attributes.Add("onclick", "javascript:return confirmDelete('" + DataBinder.Eval(e.row.DataItem, "ContactName") + "', '" + DataBinder.Eval(e.row.DataItem, "CustomerID") + "');"); } } catch(Exception objExp) { // handle exception } }

Regards,

更多推荐

通过单击警告框的“确定”按钮在警报框中显示数据

本文发布于:2023-11-27 15:51:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638635.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   单击   框中   按钮   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!