首页 新闻 会员 周边

GridView删除弹出框,为什么弹不出来,各位大虾,麻烦看看代码

0
悬赏园豆:10 [已关闭问题] 关闭于 2012-05-30 15:45

后台代码

 protected void gvAreaList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
       if (e.Row.RowType == DataControlRowType.DataRow)
        {
         if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
          {
            ((LinkButton)e.Row.Cells[4].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除:\"" + e.Row.Cells[1].Text + "\"吗?')");
          }
        }
    }

前台代码

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
                        ForeColor="#333333" GridLines="None"
            OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing"
            OnRowDataBound="gvAreaList_RowDataBound"
            OnRowUpdating="GridView1_RowUpdating"
            OnRowCancelingEdit="GridView1_RowCancelingEdit" >
                        <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />  

各位麻烦看下,就是弹不出来

NothingHave的主页 NothingHave | 初学一级 | 园豆:6
提问于:2012-05-28 10:11
< >
分享
所有回答(4)
0

直接把删除列转为模板列,然后加上

OnClientClick="return cinform('确定删除?');"

就行了吧

artwl | 园豆:16736 (专家六级) | 2012-05-28 10:14
-1

e.Row.Cells[4].Controls[0]这种写法有问题,你还是用上楼的吧,那个是最简单的了。

悟行 | 园豆:12559 (专家六级) | 2012-05-28 11:07

楼上的达不到我要的效果,我自己搞定了, Row.Cells[4].Controls[0]确实有问题,但不是像你说的那样,只要把4改成5就行了,因为,在GridView里面我的删除列在第五列

支持(0) 反对(0) NothingHave | 园豆:6 (初学一级) | 2012-05-28 11:27
0

 ((LinkButton)e.Row.Cells[4].Controls[0]),把4改成5就行了,删除那个列在第几列就是几(0.1.2.3.4.5这样算的)

NothingHave | 园豆:6 (初学一级) | 2012-05-28 11:29
0

一楼的方法可行

KissAngels | 园豆:109 (初学一级) | 2012-05-29 09:07
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册