protected void LinkButtonUpdate_Click(object sender, EventArgs e)
    {
        int nCount = GridView1.Rows.Count;
        int nSelectNum = 0;
        for (int i = 0; i < nCount; i++)
        {
            CheckBox CheckBox1 = GridView1.Rows[i].Cells[0].FindControl("CheckBox1") as CheckBox;
            if (CheckBox1.Checked)
            {
                nSelectNum++;
            }
        }
        if (nSelectNum > 1)
        {
            Response.Write("<script>alert('不能选择多个记录进行修改!')</script>");
        }
        else
        {
            nCount = GridView1.Rows.Count;
            for (int i = 0; i < nCount; i++)
            {
                CheckBox CheckBox1 = GridView1.Rows[i].Cells[0].FindControl("CheckBox1") as CheckBox;
                if (CheckBox1.Checked)
                {
                    int bianhaoID = Convert.ToInt32(GridView1.Rows[i].Cells[1].Text);
                    Response.Redirect("update.aspx?BHID="+bianhaoID);
                }
            }
        }    }

解决方案 »

  1.   

    Response.Redirect("update.aspx?BHID="+bianhaoID); 
    //
    Response.Redirect("update.aspx?BHID="+bianhaoID.ToString());
      

  2.   

    LZ。
     int bianhaoID = Convert.ToInt32(GridView1.Rows[i].Cells[1].Text); 
                        Response.Redirect("update.aspx?BHID="+bianhaoID); 你不感觉你自己做画蛇添足吗?
      

  3.   

    GridView1.Rows[i].Cells[1].Text
    格式不对嘛
    这段代码太多多余的地方了
      

  4.   

    int bianhaoID = Convert.ToInt32(GridView1.Rows[i].Cells[1].Text);
      

  5.   

    int bianhaoID = Convert.ToInt32((GridView1.Rows[i].Cells[1].Controls[0] as TextBox).Text);
      

  6.   

    string url=String.Formatupdate.aspx?BHID={0}", bianhaoID);
    Response.Redirect(url); 你看一下这种写法可以吗
    要学会自己调试发现问题,然后解决.
      

  7.   


                int nCount = GridView1.Rows.Count;
                int nSelectNum = 0,index = -1;
                for (int i = 0; i < nCount; i++)
                {
                    if ((GridView1.Rows[i].Cells[0].FindControl("CheckBox1") as CheckBox).Checked)
                    {
                        nSelectNum++;
                        if (nSelectNum > 1)
                        {
                            Response.Write(" <script>alert('不能选择多个记录进行修改!') </script>");
                            return;
                        }
                        index = i;
                    }
                }
                if (index != -1)
                {
                    Response.Redirect("update.aspx?BHID=" + GridView1.Rows[i].Cells[1].Text);
                }
      

  8.   


                int nCount = GridView1.Rows.Count;
                int nSelectNum = 0, index = -1;
                for (int i = 0; i < nCount; i++)
                {
                    if ((GridView1.Rows[i].Cells[0].FindControl("CheckBox1") as CheckBox).Checked)
                    {
                        nSelectNum++;
                        if (nSelectNum > 1)
                        {
                            Response.Write(" <script>alert('不能选择多个记录进行修改!') </script>");
                            return;
                        }
                        index = i;
                    }
                }
                if (index != -1)
                {
                    Response.Redirect("update.aspx?BHID=" + GridView1.Rows[index].Cells[1].Text);
                }