就是单击gridview的单元格进行编辑时,每单击一次单元格进行编辑时,页面都会刷新一次,怎样使单击单元格页面不再刷新
后台代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Data.SqlClient;
public partial class Rdlcs_rp_nmjbqk : System.Web.UI.Page
{
    Ref.DAL.T_refugee_total DAL_T_refugee_total = new Ref.DAL.T_refugee_total();
    Ref.Model.T_refugee_total Mod_T_refugee_total = new Ref.Model.T_refugee_total();
    public string Report_ID
    {
        get
        {
            if (ViewState["Report_ID"] != null)
            {
                return ViewState["Report_ID"].ToString();
            }
            else
            {
                ViewState.Add("Report_ID", "");
                return ViewState["Report_ID"].ToString();
            }
        }
        set
        {
            ViewState["Report_ID"] = value;
        }
    }
    int _firstEditCellIndex = 2;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
          InitPageInfo();
        }
    }
   
    
    private void InitPageInfo()
    {
           if (Report_ID.ToString() == "")
            {            }
            else
            {
                Report_ID = Request.QueryString["id"].ToString();
                DataSet ds = new DataSet();
                string sql = "select * from T_refugee_total where Report_ID='" + Report_ID + "'";
                ds = Ref.DAL.DbHelperSQL.Query(sql);
                this.GridView1.DataSource = ds;
                this.GridView1.DataBind();
            }
       }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton _singleClickButton = (LinkButton)e.Row.Cells[0].Controls[0];
            string _jsSingle = ClientScript.GetPostBackClientHyperlink(
                _singleClickButton, "");            for (int columnIndex = _firstEditCellIndex; columnIndex <
                e.Row.Cells.Count; columnIndex++)
            {
                string js = _jsSingle.Insert(_jsSingle.Length - 2,
                    columnIndex.ToString());
                e.Row.Cells[columnIndex].Attributes["onclick"] = js;
                e.Row.Cells[columnIndex].Attributes["style"] +=
                    "cursor:pointer;cursor:hand;";
            }
        }
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        switch (e.CommandName)
        {
            case ("SingleClick"):
                int _rowIndex = int.Parse(e.CommandArgument.ToString());
                int _columnIndex = int.Parse(Request.Form["__EVENTARGUMENT"]);
                this.GridView1.SelectedIndex = _rowIndex;
                this.GridView1.DataBind();
                Control _displayControl = this.GridView1.Rows[_rowIndex].Cells[_columnIndex].Controls[1];
                _displayControl.Visible = false;
                Control _editControl = this.GridView1.Rows[_rowIndex].Cells[_columnIndex].Controls[3];
                _editControl.Visible = true;
                this.GridView1.Rows[_rowIndex].Cells[_columnIndex].Attributes.Clear();
                ClientScript.RegisterStartupScript(GetType(), "SetFocus",
                    "<script>document.getElementById('" + _editControl.ClientID + "').focus();</script>");
                if (_editControl is DropDownList && _displayControl is Label)
                {
                    ((DropDownList)_editControl).SelectedValue = ((Label)_displayControl).Text;
                }
                if (_editControl is TextBox)
                {
                    ((TextBox)_editControl).Attributes.Add("onfocus", "this.select()");
                }                break;
        }
    }
     protected override void Render(HtmlTextWriter writer)
    {
         foreach (GridViewRow r in GridView1.Rows)
        {
            if (r.RowType == DataControlRowType.DataRow)
            {
                for (int columnIndex = _firstEditCellIndex; columnIndex < r.Cells.Count; columnIndex++)
                {
                    Page.ClientScript.RegisterForEventValidation(r.UniqueID + "$ctl00", columnIndex.ToString());
                }
            }
        }        base.Render(writer);
    }
    protected void btn_fh_Click(object sender, EventArgs e)
    {
        Response.Redirect("T_Report_Information.aspx");
    }
    protected void btn_save_Click(object sender, EventArgs e)
    {        string sql1 = "Data Source=PC-201108100915;Initial Catalog=Refugee40;Persist Security Info=True;User ID=sa;Password=hx";
        SqlConnection conn = new SqlConnection(sql1);
        SqlCommand selectCMD = new SqlCommand("SELECT * FROM T_refugee_total where Report_ID='" + Report_ID + "'", conn);
        DataTable dt = new DataTable();
        SqlDataAdapter sda = new SqlDataAdapter(selectCMD);
        sda.Fill(dt);
        for (int i = 0; i <this.GridView1.Rows.Count; i++)
        {
            for (int j = 2; j < this.GridView1.Columns.Count; j++)
            {
                Control _displayControl = this.GridView1.Rows[i].Cells[j].Controls[1];
                Control _editControl = this.GridView1.Rows[i].Cells[j].Controls[3];
                if (_editControl.Visible)
                {
                    dt.Rows[i][j+2] = Convert.ToInt32(((TextBox)this.GridView1.Rows[i].Cells[j].Controls[3]).Text.ToString());
                }
            }
        }
        SqlCommandBuilder scb = new SqlCommandBuilder(sda);
        sda.Update(dt.GetChanges());
        dt.AcceptChanges();
    }
}