点击gridview的某一行的任何一个地方,如何能取到点击的是哪一行???

解决方案 »

  1.   

    太简单了   在gv的mouseup事件里面
    如此这般//datagrid的整行选择
    private void dg_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    //整行选择
    if(e.Button==System.Windows.Forms.MouseButtons.Left)
    {
    dg.Select(dg.CurrentRowIndex);
    tt_id.Text=dg[dg.CurrentCell.RowNumber,0].ToString();
    tt_name.Text=dg[dg.CurrentCell.RowNumber,1].ToString();
    }
    if(dg[dg.CurrentCell].GetType().ToString()=="System.Boolean")
    {
    if(dg[dg.CurrentCell].ToString()=="True")
    {
    dg[dg.CurrentCell]=false;
    }
    else
    {
    dg[dg.CurrentCell]=true;
    }
    }
    }
      

  2.   

    protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
        e.Row.Attributes["OnClick"] =                   ClientScript.GetPostBackEventReference(this,"Select$" + e.Row.RowIndex);
                e.Row.Style["cursor"] = "hand";
      }
    }
      

  3.   

    这个事件要定义在哪啊??我找了找就没有这样的定义方法阿!!!在.net2.0下的