我想实现:
   点击datagrid 中的linkbutton,根据数据的状态确定是否可以修改.
if status="a" then
   弹出提示框,点击"确定",response.redirect("a.aspx")
else
   response.redirect("b.aspx")
end if请教高手!

解决方案 »

  1.   

    gridview 的RowDataBound事件中为每一行的linkbutton添加前台事件:    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    LinkButton lb = e.Row.FindControl("lnkbtnID") as LinkButton;
                     if(e.Row[0]=="a")
                     {
                    lb.Attributes.Add("onclick", "if(confirm('确定要XXX吗?')){window.location.href='~/a.aspx;'return true;}else{return false;}");
                      }
                       else  lb.Attributes.Add("onclick", "window.location.href='~/b.aspx;');
                }
      

  2.   

    提示框显示“状态为a的数据不能修改!”不应该用confirm()吧?
      

  3.   

    datagrid
    我这里就随便找个事件写了 具体写在那个事件里边 以你自己而定private void DataGrid1_ItemDataBound(object sender,System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    //点击"删除"按钮后弹出确认对话框
        if(e.Item.FindControl("btnDelete1")!=null)//这里你自己就改一下 获取你那个什么A
        {
           ((LinkButton)e.Item.FindControl("btnDelete1")).Attributes.Add("onclick", "if(confirm('提示信息')){window.location.href='~/a.aspx;'return true;}else{return false;}");
        }
    else{
    ......
    }
    }
      

  4.   

    linkbutton的属性里面设置:
    onclientclick="renturn confirm('你确认...吗?"
      

  5.   

     response.write("<script>alert('ok')</script>");
    还有好几种网上查查看
      

  6.   

    response.write("<script>confirm('ok'){window.location.href='b.aspx'}</script>");
      

  7.   

    弹出提示框,点击"确定",response.redirect("a.aspx")替换response.write("<script>confirm('ok'){window.location.href='b.aspx'}</script>");
      

  8.   


    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "提示", "alert(\"没有相关新闻\");window.location.href = '/Defaultv1.aspx';", true);
                     ScriptManager.RegisterStartupScript(this, GetType(), "", "alert('友链不能输入空值!');", true);
      

  9.   


    <ItemTemplate>
           <asp:LinkButton ID="LinkButton1" runat="server" Text='修改' CommandArgument='<%#Eval("status")%>' OnCommand="LinkButton1_Command">
           </asp:LinkButton>
    </ItemTemplate> 后台:
    public void LinkButton1_Command(object sender,CommandEventArgs)
    {
         string status = e.CommandArgument.ToString().Trim();
         if(status=="a")
         {
               Response.Redirect("a.aspx");
         }
         else
         {
               Response.Redirect("b.aspx");
         }
    }