我是从函数中返回一个dataset   然后绑定到一个datagrid   上的 函数:   函数名:cc 
                public   void   EditPerson(int   PersonNo)//修改人员(删除人员) 
                { 
                        SqlCommand   myCommand   =   new   SqlCommand(); 
                        myCommand.Connection   =   MySqlConn; 
                        MySqlConn.Open(); 
                        myCommand   =   new   SqlCommand("Pr_EditPerson",   MySqlConn); 
                        myCommand.Parameters.AddWithValue("@PersonNo",   PersonNo); 
                        myCommand.CommandType   =   CommandType.StoredProcedure; 
                        myCommand.ExecuteNonQuery(); 
                        MySqlConn.Close(); 
                  } 
              public   DataSet   GetAllPerson()//查询所有人员 
                { 
                        SqlCommand   myCommand   =   new   SqlCommand(); 
                        myCommand.Connection   =   MySqlConn; 
                        myCommand   =   new   SqlCommand("Pr_GetAllPerson",   MySqlConn); 
                        myCommand.CommandType   =   CommandType.StoredProcedure; 
                        SqlDataAdapter   MysqlAdapter   =   new   SqlDataAdapter(myCommand); 
                        MysqlAdapter.Fill(ds); 
                        return   ds;                 } 然后后台代码的   form1   如此绑定数据到datagrid                           DSP   =   cc.GetAllPerson(); 
                        dataGrid1.SetDataBinding(DSP.DefaultViewManager,   ""); 
                        this.dataGrid1.ReadOnly   =   true; 
但为什么这个时候在dataGrid1.SetDataBinding(DSP.DefaultViewManager,   "123");   的“123”中写入   内容就会出现错误,错误为,“无法创建字段   123   的子列表”,如果不写入内容,就会运行,而且datagrid中也有数据,这个是为什么呢?????   不知道。~问题一~ 第二个问题是: 我想修改数据库表的数据,但我在这个datagrid中无法选择我所选择的光标的   行! 
                            PersonNo   =System.Convert.ToInt32(   this.dataGrid1[dataGrid1.CurrentRowIndex,   0].ToString()); 
                        MessageBox.Show(PersonNo   +   ""); 
                        cc.EditPerson(PersonNo); 
                        DSP.Clear(); 
                        MyDGD(); 
                
我想得到我所选择的光标所在处的行的第一个咧的数据,但这样写入的话,我得到的是,为什么总是,第一个行的第一个列的数据??????而不是地n(光标所在处)个行的第一个数据???请大家帮帮忙!!!   打死也不会了。 

解决方案 »

  1.   

    not 高手,过来看看~~==================================================================
    博客空间:http://blog.csdn.net/lovingkiss
    资源下载:http://download.csdn.net/user/lovingkiss
    Email:loving-kiss@163.com
    优惠接单开发,组件控件定制开发,成品源代码批发
    联系方式:Q66840199  全天在线
    ==================================================================
      

  2.   

    第一个没用过defaultviewmanager
    第二个用
    this.dataGrid1[this.dataGrid1.CurrentCell.RowNumber,       0]
      

  3.   

    啊! 第二个解决了,但是想问为什么 不能用dataGrid1.CurrentRowIndex呢? 
      

  4.   

    not 高手  特来扰一下~
      

  5.   

    !高手;
    but while(true)
    {
    打扰();
    }