我在GridView数据列表页面执行了删除操作,然后重新绑定数据。想在删除成功后alert一个删除成功信息:执行删除  
Response.Write("<script>alert('删除成功!)'</script>");
重新绑定为什么alert以后页面的GridView的显示样式(字体、交错项的颜色)就不起作用呢?如果不加那句alert倒是正常的!这是为什么啊?

解决方案 »

  1.   

    把gridview所在的页面的界面和后台代码贴出来看一下
      

  2.   

    应该是alert在页面之前显示了
      

  3.   

    页面代码: 反正好几个地方能设置列表的样式(项设置?整个gridview的行设置?利用事件在行创建时写入样式?……),到底应该怎么设置啊?
                    <asp:GridView ID="pj_GridView" runat="server" style="width: 100%; border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none;" AutoGenerateColumns="False" OnRowDataBound="pj_GridView_RowDataBound" OnRowDeleting="pj_GridView_RowDeleting" OnRowUpdated="pj_GridView_RowUpdated" DataKeyNames="pjid">
                        <Columns>
                            <asp:TemplateField>
                                <EditItemTemplate>
                                    <asp:CheckBox ID="CheckBox1" runat="server" />
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="CheckBox1" runat="server" />
                                </ItemTemplate>
                                <ControlStyle Width="20px" />
                                <ItemStyle Width="20px" CssClass="mlth1" />
                                <HeaderStyle Height="20px" CssClass="mlth" />
                            </asp:TemplateField>
                            <asp:BoundField DataField="pjbrand" HeaderText="品牌" >
                                <ItemStyle Width="80px" CssClass="mlth1" />
                                <HeaderStyle CssClass="mlth" />
                            </asp:BoundField>
                            <asp:BoundField DataField="pjname" HeaderText="名称" >
                                <ItemStyle Width="150px" CssClass="mlth1" />
                                <HeaderStyle CssClass="mlth" />
                            </asp:BoundField>
                            <asp:BoundField DataField="pjdetail" HeaderText="说明" >
                                <HeaderStyle CssClass="mlth" />
                                <ItemStyle CssClass="mlth1" />
                            </asp:BoundField>
                            <asp:BoundField DataField="pjprice" HeaderText="价格" >
                                <ItemStyle Width="50px" CssClass="mlth1" />
                                <HeaderStyle CssClass="mlth" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="操作">
                                <ItemStyle CssClass="mlth1" Width="80px" />
                                <HeaderStyle CssClass="mlth" />
                                <ItemTemplate>
                                    <asp:LinkButton ID="lbtn_update" runat="server" CommandName="update">修改</asp:LinkButton>
                                    &nbsp;<asp:LinkButton ID="lbtn_delete" runat="server" CommandName="delete">删除</asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <RowStyle Height="20px" BackColor="#F6F6F6" />
                     </asp:GridView>
      

  4.   

    alert在绑定之前之后一样,除非再加个location.reload()让也面重新刷新就可以,不过这样好象不太……
      

  5.   

    把Response.Write("<script>alert('删除成功!)'</script>");改成
    ((Page)HttpContext.Current.Handler).RegisterStartupScript("", "<script>alert(\"" + "删除成功" + "\");</script>");
    PS:你写的那个本身就有语法错误
      

  6.   

    赞同楼上的,不能用RESPONSE.WRITE
      

  7.   

    ok 搞定了 不过编译的时候好象有警告信息:警告 1 “System.Web.UI.Page.RegisterStartupScript(string, string)”已过时:“The recommended alternative is ClientScript.RegisterStartupScript(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202”说什么已经过时?? 还有最新的实现方法吗??
      

  8.   

    发生这种情况的原因为web2.0不允许有其它语言在整个html之上。即<html>之前不能有script语言之类的。
    解决办法就是控制你的脚本输出的位置,而不是简单的用一个Response.Write就行了。
      

  9.   

    支持criedshy(哭泣的天空)的答案。也可以尝试
    this.RegisterStartupScript("alert", "<script language=javascript>window.alert('删除成功!');</script>");
      

  10.   

    原:Response.Write("<script>alert('删除成功!)'</script>");
    现:Response.Write("<script>alert('删除成功!')</script>");楼主看清了没?
    你的Javascript语法写错了。
    楼上的都是笨蛋么?
      

  11.   

    楼上的,你骂人就不好了嘛~~呵呵 虽然是写错了,不过问题的关键不在那里。
    看来只能支持criedshy(哭泣的天空)的答案,虽然还是提示语法过……晚上揭贴