单击GridView上某一行,触发一个事件并取得该行的主键值,这个代码该怎么写?

解决方案 »

  1.   

            private void bsCustInfo_CellClick(object sender, DataGridViewCellEventArgs e)
            {
                int i = e.RowIndex;
                bs_cust_info.Rows[i].Cells[“你想要取主键的列名"].Value.ToString();
                
            }
      

  2.   

    添加行编辑事件,然后就可以得到id  //当按下详细信息按钮时,弹出sell_open页面,并将id值传递过去
            protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
            {
                string id = GV.DataKeys[e.NewEditIndex].Value.ToString();
                
                UIHelper.OpenWindow(this.Page, "Sell_open.aspx?id=" + id, 400, 500, 100, 100, "ok");
                
            }如果你想得到某一行某一列的值的话,支持楼上的....