protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {        if (e.Row.RowType == DataControlRowType.Header)
        {
            return;
        }
        if (e.Row.RowType == DataControlRowType.DataRow)
        { }
        PostBackOptions pb = new PostBackOptions(this);        pb.AutoPostBack = false;
        pb.RequiresJavaScriptProtocol = true;
        pb.PerformValidation = false;
        String  Evt = Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex.ToString());        e.Row.Attributes.Add("Onclick", Evt);        e.Row.Attributes["Style"] = "Cursor:hand";  
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int UserID = Convert.ToInt16(GridView1.SelectedRow.Cells[0].Text);        DataTable dt = GetUserInfo(UserID);        this.txtName.Text = dt.Rows[0]["Name"].ToString();        this.txtUsername.Text = dt.Rows[0]["UserName"].ToString();        this.txtPassword.Text = dt.Rows[0]["PassWord"].ToString();   
    }

解决方案 »

  1.   

      protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {        if (e.Row.RowType == DataControlRowType.Header)
            {
                return;
            }
            if (e.Row.RowType == DataControlRowType.DataRow)
            { }
            PostBackOptions pb = new PostBackOptions(this);        pb.AutoPostBack = false;
            pb.RequiresJavaScriptProtocol = true;
            pb.PerformValidation = false;
            String  Evt = Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex.ToString());        e.Row.Attributes.Add("Onclick", Evt);        e.Row.Attributes["Style"] = "Cursor:hand";  
        }
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int UserID = Convert.ToInt16(GridView1.SelectedRow.Cells[0].Text);        DataTable dt = GetUserInfo(UserID);        this.txtName.Text = dt.Rows[0]["Name"].ToString();        this.txtUsername.Text = dt.Rows[0]["UserName"].ToString();        this.txtPassword.Text = dt.Rows[0]["PassWord"].ToString();   
        }
      

  2.   

      protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {        if (e.Row.RowType == DataControlRowType.Header)
            {
                return;
            }
            if (e.Row.RowType == DataControlRowType.DataRow)
            { }
            PostBackOptions pb = new PostBackOptions(this);        pb.AutoPostBack = false;
            pb.RequiresJavaScriptProtocol = true;
            pb.PerformValidation = false;
            String  Evt = Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex.ToString());        e.Row.Attributes.Add("Onclick", Evt);        e.Row.Attributes["Style"] = "Cursor:hand";  
        }
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int UserID = Convert.ToInt16(GridView1.SelectedRow.Cells[0].Text);        DataTable dt = GetUserInfo(UserID);        this.txtName.Text = dt.Rows[0]["Name"].ToString();        this.txtUsername.Text = dt.Rows[0]["UserName"].ToString();        this.txtPassword.Text = dt.Rows[0]["PassWord"].ToString();   
        }
      

  3.   

    楼上的是Web的GridView,跟DataGridView还是有不同的。
    private void DGV_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
            {
                if (e.RowIndex < 0)
                {            }
                else
                {
                    String ID = this.DGV.Rows[e.RowIndex].Cells[0].Value.ToString();//获得本行第一个单元格的数据,以此类推
                }
            }
      

  4.   

    楼上的是Web的GridView,跟DataGridView还是有不同的。
    private void DGV_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
            {
                if (e.RowIndex < 0)
                {            }
                else
                {
                    String ID = this.DGV.Rows[e.RowIndex].Cells[0].Value.ToString();//获得本行第一个单元格的数据,以此类推
                }
            }
      

  5.   

    楼上的是Web的GridView,跟DataGridView还是有不同的。
    private void DGV_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
            {
                if (e.RowIndex < 0)
                {            }
                else
                {
                    String ID = this.DGV.Rows[e.RowIndex].Cells[0].Value.ToString();//获得本行第一个单元格的数据,以此类推
                }
            }