单击按钮并检查数据库中的数据后显示警报 [英] display an alert after both clicking a button and checking data from database

查看:55
本文介绍了单击按钮并检查数据库中的数据后显示警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在单击位于网格视图每一行的超链接删除"后,该超链接列出了培训,我检查受训者是否没有将其分配给与删除有关的培训,然后显示警报消息(如果存在)分配给培训的任何受训者,如果不删除培训,则必须删除

i want that after clicking a hyperlink "delete" located at each row of my gridview which lists trainings that i check if a trainee wasn''t assign to the training concerned by the delete, then display a alert message if there is any trainee assigned to the training and if not to delete the training

推荐答案

在gridview的rowdatacommand事件中进行编码

当arg命令被删除时,创建一个与您在ur情况下所用类型相同的受训对象(我希望您在这种情况下必须已带有标签)
检查文本是否不存在,或者您的逻辑是检查受训者是否存在
然后检查(!traineepresent)
{
从后面的代码中调用javascript来显示ur消息.
}

Coding need to be done at rowdatacommand event of gridview

when the command arg is delete create a trainee object of same type what u have taken in ur case ( i hope you must have taken label in this case )
check if the text is not present or what ever ur logic is to check if trainee present or not
then check if (!traineepresent)
{
call javascript to display ur message from code behind.
}

ScriptManager.RegisterStartupScript(
                        this,
                        typeof(string),
                        "allertmessagefunctionname",
                        "allertmessagefunctionname();",
                        true);



希望该解决方案对您有用



Hope the solution will work for you


我希望在单击位于网格视图每一行的超链接删除"后,该链接列出了我检查受训人员是否参加过的培训"通过删除将其分配给相关培训
要在数据表上添加删除提示(看起来像是UI中的数据网格),您需要绑定javascript以在数据网格的ItemDataBound/RowDataBound事件期间提示此警报.

在这种情况下,当数据逐行绑定时,请添加以下内容:
i want that after clicking a hyperlink "delete" located at each row of my gridview which lists trainings that i check if a trainee wasn''t assign to the training concerned by the delete
For adding a delete prompt on a datatable (looks like its going to be a datagrid in UI), you would need to bind the javascript to prompt for this alert during the ItemDataBound/RowDataBound event of the datagrid.

In this event, while the data is binded row by row - add something like:
LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");
l.Attributes.Add("onclick", "javascript:return " +
    "confirm(''Are you sure you want to delete this record'')"); 



或者,
如果datagrid的ItemTemplate中的链接按钮暴露了OnclientClick事件(在ASP.NET2.0及更高版本中存在),则可以添加以下内容:



Alternatively,
if the link button in ItemTemplate of datagrid has OnclientClick event exposed (which is present in ASP.NET2.0 onwards), you can add something like:

OnClientClick = ''return confirm("Are you sure you want to delete this entry?");'' 



参考: MSDN:删除时添加客户端确认 [



Refer: MSDN: Adding Client-Side Confirmation when Deleting[^]


hen display a alert message if there is any trainee assigned to the training and if not to delete the training
For this, just show the thing in a label text. Showing it in an alert window would not be good idea for the purpose. Once DB update fails, show that as a red label text on the page.


您必须在服务器端进行所有删除逻辑处理.因此,您的问题基本上可以归结为在服务器端满足的某些条件下向用户显示消息框(警报).

我想您会发现这对您的情况很有用

用于ASP.NET网站的类似于MessageBox的Windows窗体 [ ^ ]
you must be doing all the delete logic processing on server side. So you problem basically boils down to showing a messagebox(alert) to the user on some conditions that are met on serverside.

I think you can find this useful for your scenario

A Windows Form like MessageBox for ASP.NET Website[^]


这篇关于单击按钮并检查数据库中的数据后显示警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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