如题

解决方案 »

  1.   

    不是模板烈的话:GridView1.SelectedRow.Cells[0].Text;
    模板列要进行相应的转换。
      

  2.   

    二楼好像不对啊
    老提示System.NullReferenceException: 未将对象引用设置到对象的实例
      

  3.   

     GridView1.Rows[GridView1.SelectedIndex].Cells[1].Text;
      

  4.   

    5楼的话
    提示索引超出范围。必须为非负值并小于集合大小。
    参数名: index 
      

  5.   

    GridView1.SelectedIndex是获取控件中选中行的索引
      

  6.   

    GridView1.SelectedIndex...
      这个要选择了那行之后才有值,没选择当然 超出索引了
      
      

  7.   

    我的意思是
    能否在
     protected void gr_planadmin_RowCommand(object sender, GridViewCommandEventArgs e)
        {
     
            if (e.CommandName == "content")
            {
               
            }
        }
    这个条件下
    取出某个gridview选中行中某个字段的值
      

  8.   

    在HTML中使用 CommandName = "Name" CommandAgrument ="<%KEY%>"
    在程序中使用 
    IF(E.COMMANDNAME=="Name")
    {
        String str = e.CommandAgrument.ToString();
    }
    我一般就这么来做,比较安全实用
      

  9.   

    比如取出当前行ID这个列的值并且转化为字符串的代码如下:GridView.Rows[e.Row.Index].Cells["id"].Value.ToString();
      

  10.   

    直接绑定数据到CommandAgument不就行了。
    Command事件的基本用法吗
      

  11.   

    可是我现在的情况是CommandAgument中已经绑定了一个了
      

  12.   

    commandname   commandargument     网上查查,自己体会.
      

  13.   

    dataGridView1.CurrentRow.Cells["列名"].Value.ToString();
    一定可以! lz试试