这1列数据库为 identity现在取出来值都是“”,大家有没有碰到过?怎么解决?

解决方案 »

  1.   

    this.dataGridView1.Rows[0].Cells[0].Value.ToString();
    int.Parsse(this.dataGridView1.Rows[0].Cells[0].Value.ToString());
      

  2.   

    this.dataGridView1.Rows[0].Cells[1].Value.ToString();
      

  3.   

    我的是GridView1,asp,没有value这个属性
      

  4.   

    Tabale 的 值 为空?
    dataGridView1.Rows[0].Cells[1].ValuedataGridView1.Rows[0][1].tostring()或dataGridView1.Rows[0][“字段名”].tostring()
      

  5.   

    if(IsPostBack)
    {
        
    }
      

  6.   

    控件 obj =  this.dataGridView1.Rows[0].FindControl as 控件
    obj.属性  
    你看下生成出来的事什么
      

  7.   

    this.dataGridView1.Rows[0].Cells[0].Value.ToString();
      

  8.   

    我是先load中给gridveiw绑定数据
    if (!Page.IsPostBack)
            {
                loaddata();            
            }
    然后GridView1_RowCommand()
    中取值,其他什么都没做若不是 自增长列,这个方法没问题呀,就ID取不到
      

  9.   

    this.dataGridView1.Rows[0].Cells[0].Text.ToString();
      

  10.   

      protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "lnk_edit")
            {
                int index = Convert.ToInt32(e.CommandArgument);            string strid = GridView1.Rows[index].Cells[0].Text.ToString();
                string strname = GridView1.Rows[index].Cells[2].Text.ToString();    
            }
    }
      

  11.   

    void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
     //让索引为0的列不可见,实际上是产生的css代码
     e.Row.Cells[0].Visible = false;
     //other code if neccecary
    }最后发现是隐藏列的问题,与数据库无关,加上这个方法就可以了,谢谢大家啊
      

  12.   

    TableCell cell = drplist.Parent as TableCell;
                    var row = cell.Parent as GridViewRow;
                    int rownum = row.RowIndex;
                    string str = spgridview.Rows [rownum].Cells [0].Text