• 删除确认提示


    以前好像找了好多帖,大多是下面这个做法
    private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
      {
         for(int i=0;i<this.DataGrid1.Items.Count;i++)
         {
          LinkButton lb = (LinkButton)this.DataGrid1.Items[i].Controls[3].Controls[0];
          lb.Attributes.Add("onclick","javascript:if(!window.confirm('您确认要删除吗?')) return false;");
         }
    }

    我不清楚当年为什么有人会帖出这样的代码。效率好像不是太好。不过反正没问题。也就收到自己的小本子里了。
    不过今天碰上个麻烦。
    private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
      {
           if(e.Item.Cells[0].Text!=Session["PERSON_ID"].ToString())//不是自己的帖,删除按钮不可见
        {
         if(e.Item.ItemType!=ListItemType.Header)
          e.Item.Cells[3].Text="";
        }
        else
        {
         LinkButton lb =((LinkButton)e.Item.Cells[3].Controls[0]);
         lb.Attributes.Add("onclick","javascript:if(!window.confirm('您确认要删除吗?')) return false;");
    //只能用上面这个方法。不然会因为上面这种情况在我把e.Item.Cells[3]的Control删除后,造成索引失败。代码效率也好多了。
         /*
         for(int i=0;i<this.DataGrid1.Items.Count;i++)
         {
          LinkButton lb = (LinkButton)this.DataGrid1.Items[i].Controls[3].Controls[0];
          lb.Attributes.Add("onclick","javascript:if(!window.confirm('您确认要删除吗?')) return false;");
         }
         */
        }
       }   
      }
    PS:(真是弄不懂。今天怎么又出了个首页原创技术区的网站分类^_^0

  • 相关阅读:
    无法为该请求检索数据。 (Microsoft.SqlServer.Management.Sdk.Sfc)
    java.net.NoRouteToHostException: No route to host
    Microsoft SQL Server,错误: 1807
    System.Data.SqlClient.SqlError: 该数据库是在运行版本 8.00.0194 的服务器上备份
    jfinal 日志log4j使用
    遇见未来系列专访 | 聆听时代最前沿的声音
    Html5新增元素中Canvas 与内联SVG的比较
    Raphael JS
    Raphael.js简易教程
    jfinal--乱码问题
  • 原文地址:https://www.cnblogs.com/tongzhenhua/p/16583.html
Copyright © 2020-2023  润新知