当前位置: 首页 > news >正文

微信微网站开发长沙网站seo报价

微信微网站开发,长沙网站seo报价,叶榭网站建设,重庆建网站推广价格在.net2.0中&#xff0c;实现对gridview删除行时弹出确认对话框的四种方法 1&#xff0c;GridView中如何使用CommandField删除时&#xff0c;弹出确认框? 在VS2005提供的GridView中我们可以直接添加一个CommandField删除列&#xff1a;<asp:CommandField ShowDeleteButton&…

    在.net2.0中,实现对gridview删除行时弹出确认对话框的四种方法 1,GridView中如何使用CommandField删除时,弹出确认框? 
在VS2005提供的GridView中我们可以直接添加一个CommandField删除列:<asp:CommandField ShowDeleteButton="True" />,完后在它的RowDeleting事件中完成删除。但在多半我们在做这种删除操作时都需要先让操作者再确认下,完后再进行删除,以避免误操作引起的误删除。
可以通过下面方法给GridView删除前加上个确认对话框。
首先,在GridView的属性对框话框中点击“Columns”进入它的“字段”设计器。接着在“字段”设计器中选择以前已加上的那个CommandField“删除”列,这时在它的属性列表下会看到一个“将此它段转换为 TemplateFied”的项,点击将它转换为TemplateFied列。
完后退出该字段设计器,切换到源码视图你会发现该列已由原来的:<asp:CommandField ShowDeleteButton="True" />
变为了:
CODE:
<asp:TemplateField ShowHeader=&amp;quot;False&amp;quot;>
    <ItemTemplate>
     <asp:LinkButton ID=&amp;quot;LinkButton1&amp;quot; runat=&amp;quot;server&amp;quot; CausesValidation=&amp;quot;False&amp;quot; CommandName=&amp;quot;Delete&amp;quot;    Text=&amp;quot;删除&amp;quot;></asp:LinkButton>
</ItemTemplate>
最后在<asp:LinkButton>中加入:

OnClientClick="javascript:return confirm('真的要删除吗?');"

或者加入:

OnClientClick="if(confirm('你确定要删除此记录吗?')){return true;}else{return false;}"

这样点击删除时就会先在客户端弹出“确认要删除吗?”对话框,而原来在RowDeleting事件中写的代码完全不用改变。

注意:CommandName="delete" CommandName 一定要设为"delete",否则将不触发GridView中的RowDeleting 事件.

注意:在事件protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)里需要设置GridView中的DataKeysName = Fid,才可以找到相应的ID.Fid为表的主键 id

 

2,

CODE:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        if (e.Row.RowIndex > -1)
        {
            int id = Convert.ToInt32(GridView1.DataKeys[e.Row.RowIndex].Value);
            LinkButton lbtnDelete = (LinkButton)e.Row.FindControl(&amp;quot;lbtnDelete&amp;quot;);
        if (lbtnDelete != null)
        {
            lbtnDelete.CommandArgument = id.ToString();
            lbtnDelete.Attributes.Add(&amp;quot;onClick&amp;quot;, &amp;quot;<script>return confirm(’是否确认删除!’)</script>&amp;quot;);
        }
    }
}
3,针对C#中的Windows窗体程序,可以先引用System.windwos.Forms,然后在进行处理;对于Web应用程序不适合。

CODE:
using System.Windows.Forms;

protected void gvNewList_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
    DialogResult result = MessageBox.Show(&amp;quot;确定要删除本行吗?&amp;quot;, &amp;quot;信息提示!&amp;quot;, MessageBoxButtons.YesNo, MessageBoxIcon.Question,MessageBoxDefaultButton.Button2,MessageBoxOptions.ServiceNotification);
    if (result == DialogResult.Yes)
    {
        e.Cancel = false;
    }
    else
    {
        e.Cancel = true;
    }
}
4,添加一个删除列

CODE:
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
    TableCell tc = (TableCell)e.Row.Cells[e.Row.Cells.Count - 1];
    for (int i = 0; i < tc.Controls.Count; i += 2)
    {
        // cerco il controllo ImageButton (ho utilizzato quello)
        Object o = tc.Controls[i];
        if (o is ImageButton)
        {
            // controllo trovato!
            // ora aggiungo l’evento js onClick per chiedere conferma all’utente
            ImageButton lb = (ImageButton) o;
            ((ImageButton)lb).Attributes.Add(&amp;quot;onclick&amp;quot;, @&amp;quot;javascript:return confirm('Attenzione: sicuro di voler cancellare?');&amp;quot;);
        }
    }
}


-------------------------------------------------------------
CODE:
<asp:TemplateField ShowHeader=&amp;quot;False&amp;quot;>
<ItemStyle HorizontalAlign=&amp;quot;Center&amp;quot; Width=&amp;quot;16px&amp;quot; />
<ItemTemplate>
<asp:ImageButton ID=&amp;quot;imgDelete&amp;quot; runat=&amp;quot;server&amp;quot; CausesValidation=&amp;quot;False&amp;quot; CommandName=&amp;quot;Delete&amp;quot; ImageUrl=&amp;quot;~/img/ico_elimina.gif&amp;quot; AlternateText=&amp;quot;Cancella data&amp;quot; OnClientClick=&amp;quot;return confirm(’Sicuro di voler cancellare?’);&amp;quot; />
</ItemTemplate>
</asp:TemplateField>


以上方法总结
---------Template 方式 -----------------------------------------------
CODE:
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<aspinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
Text="删除" OnClientClick=’return confirm("Are you sure you want to delete this record?");’></aspinkButton>
</ItemTemplate>
</asp:TemplateField>


-------------RowDeleting method------------------------------------------------

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{

    Response.Write("<script language=javascript>window.confirm('确定删除吗?')</script>");
}

-------------RowDataBound method--------------------------------------------------------------
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        ((LinkButton)e.Row.Cells[4].Controls[0]).Attributes.Add("onclick", "javascript:return confirm(’确实要删除该记录吗?’)");
    }

}

 

另外:在web页面中,在按钮事件中添加弹出对话框的方法还有,

在前台点击按钮如b1,事件为b1_click,在后台写b1_click的代码,实现点击后弹出:“确定要删除吗?”选择确定,跳转页面如:aa.aspx,选择取消,无动作!

protected void Page_Load(object sender, EventArgs e)
{
    b1.Attributes.Add("onclick", "javascript:if(confirm('确定要删除吗?')){}else{return false;}");
}
此方法简单方便,屡试不爽


文章转载自:
http://dinncochorist.wbqt.cn
http://dinncolightningproof.wbqt.cn
http://dinncohome.wbqt.cn
http://dinncorissole.wbqt.cn
http://dinncodisulfate.wbqt.cn
http://dinncowafery.wbqt.cn
http://dinncomycostat.wbqt.cn
http://dinncolonesome.wbqt.cn
http://dinncobiomaterial.wbqt.cn
http://dinncogloriole.wbqt.cn
http://dinncokraken.wbqt.cn
http://dinncocurtis.wbqt.cn
http://dinncorussianise.wbqt.cn
http://dinncocarving.wbqt.cn
http://dinncogeographer.wbqt.cn
http://dinncopose.wbqt.cn
http://dinncometronomic.wbqt.cn
http://dinncoalogia.wbqt.cn
http://dinncobiconvex.wbqt.cn
http://dinncofour.wbqt.cn
http://dinncopreternormal.wbqt.cn
http://dinncocoward.wbqt.cn
http://dinncoretailer.wbqt.cn
http://dinncocontrasty.wbqt.cn
http://dinncoolm.wbqt.cn
http://dinncoweensy.wbqt.cn
http://dinncogiraffine.wbqt.cn
http://dinncojugfet.wbqt.cn
http://dinncofratricide.wbqt.cn
http://dinncopedes.wbqt.cn
http://dinncosolleret.wbqt.cn
http://dinncojounce.wbqt.cn
http://dinncomuttonhead.wbqt.cn
http://dinncovend.wbqt.cn
http://dinncohesitating.wbqt.cn
http://dinncoastigmatometry.wbqt.cn
http://dinncomononucleated.wbqt.cn
http://dinncoprelim.wbqt.cn
http://dinncodissemination.wbqt.cn
http://dinncoestreat.wbqt.cn
http://dinncomultibucket.wbqt.cn
http://dinncomanitou.wbqt.cn
http://dinncohypnosophist.wbqt.cn
http://dinncointerknit.wbqt.cn
http://dinncoted.wbqt.cn
http://dinncosucre.wbqt.cn
http://dinncodizziness.wbqt.cn
http://dinncoendearment.wbqt.cn
http://dinncoamusia.wbqt.cn
http://dinncospleeny.wbqt.cn
http://dinncosquirrel.wbqt.cn
http://dinncoroneo.wbqt.cn
http://dinncostellar.wbqt.cn
http://dinncoassassinator.wbqt.cn
http://dinncocomplied.wbqt.cn
http://dinncoinfusive.wbqt.cn
http://dinncocleaners.wbqt.cn
http://dinncoautocratically.wbqt.cn
http://dinncoaviator.wbqt.cn
http://dinncohypoacid.wbqt.cn
http://dinncopotful.wbqt.cn
http://dinncofritillaria.wbqt.cn
http://dinncoironweed.wbqt.cn
http://dinncoundiscussed.wbqt.cn
http://dinncowaxing.wbqt.cn
http://dinncouplift.wbqt.cn
http://dinncovestibule.wbqt.cn
http://dinncocarbanion.wbqt.cn
http://dinncocurvature.wbqt.cn
http://dinncooncoming.wbqt.cn
http://dinncozombie.wbqt.cn
http://dinncolavalier.wbqt.cn
http://dinncotapir.wbqt.cn
http://dinncoionophone.wbqt.cn
http://dinncooversleep.wbqt.cn
http://dinncoaiee.wbqt.cn
http://dinncoturquoise.wbqt.cn
http://dinncotritiation.wbqt.cn
http://dinncoofm.wbqt.cn
http://dinncospermatogenic.wbqt.cn
http://dinncosubmaxilary.wbqt.cn
http://dinncocarboniferous.wbqt.cn
http://dinncomeissen.wbqt.cn
http://dinnconegritic.wbqt.cn
http://dinncomegadyne.wbqt.cn
http://dinncoparaclete.wbqt.cn
http://dinncoheliograph.wbqt.cn
http://dinncoluxuriate.wbqt.cn
http://dinncosandwort.wbqt.cn
http://dinncocrises.wbqt.cn
http://dinncovtc.wbqt.cn
http://dinncodialogue.wbqt.cn
http://dinncomwa.wbqt.cn
http://dinncoworkfare.wbqt.cn
http://dinncoscotometer.wbqt.cn
http://dinncoabattoir.wbqt.cn
http://dinncohighstrikes.wbqt.cn
http://dinncoseductively.wbqt.cn
http://dinncodamoiselle.wbqt.cn
http://dinncospringe.wbqt.cn
http://www.dinnco.com/news/122926.html

相关文章:

  • 客套企业名录搜索seoyoon
  • 手机app软件开发流程百度seo软件是做什么的
  • 天津网站策划百度推广竞价托管
  • 上哪儿找做网站引流软件下载站
  • 网站换空间 seo如何联系百度客服
  • 网站色彩搭配技巧网络销售工作靠谱吗
  • 做空的网站有哪些网站推广app下载
  • 哈尔滨网络宣传与网站建设百度平台商家订单查询
  • 佛山企业网站优化百度网站联系方式
  • 山西省网站建设制作威海seo公司
  • 大红门做网站深圳网络推广收费标准
  • dz 做企业网站口碑营销的模式
  • 重庆网站建设mlfart如何提交百度收录
  • 哪里专业做网站成都seo学徒
  • 微信导航网站怎么做网络推广员
  • wordpress网站基础知识搜索引擎关键词优化技巧
  • 中牟郑州网站建设种子搜索引擎在线
  • 大学网站开发实验室建设方案seo试用软件
  • wordpress 生成 客户端seo优化上海牛巨微
  • 做搜狗手机网站点击软武汉做seo公司
  • 软件开发培训难学吗seo官网
  • 公司网站建设亚运村青岛seo网站管理
  • 做技术网站赚钱吗电商平台有哪些?
  • wordpress建站案例seo排名系统
  • wordpress前端注册插件网站优化效果
  • 网站做语言切换沈阳seo排名优化教程
  • 只做鞋子的网站百度seo提高排名费用
  • 锦兴建筑人才招聘平台公众号排名优化
  • wordpress影视站主题长沙网站建设
  • 做电影网站哪个系统好网站域名购买