日期:2014-05-19  浏览次数:20754 次

无法将数据绑定到TextBOx上面
private   void   comboBoxID_SelectedValueChanged(object   sender,   EventArgs   e)
                {
                        try
                        {
                                //SqlCommand   selectCmd   =   new   SqlCommand( "select   *   from   employee   where   cID= ' "   +   comboBoxID.SelectedItem   +   " ' ",   DBConnect.SqlConnect());
                                SqlDataAdapter   da   =   new   SqlDataAdapter( "select   *   from   employee   where   cID= ' "   +   comboBoxID.SelectedItem   +   " ' ",   DBConnect.SqlConnect());
                              //   da.SelectCommand   =   selectCmd;
                                DataSet   ds   =   new   DataSet();
                                da.Fill(ds,   "table1 ");
                                txtID.Text   =   ds.Tables[ "teble1 "].Rows[0][ "cID "].ToString();
                                txtName.Text   =   ds.Tables[ "table1 "].Rows[1][ "cName "].ToString();
                                txtPwd.Text   =   ds.Tables[ "table1 "].Rows[2][ "vPassword "].ToString();
                                dateTimePicker1.Text   =   ds.Tables[ "table1 "].Rows[3][ "dBirthday "].ToString();
                                txtAge.Text   =   ds.Tables[ "table1 "].Rows[4][ "cAge "].ToString();
                                comboBoxSex.SelectedItem   =   ds.Tables[ "table1 "].Rows[5][ "cSex "].ToString();
                                txtNation.Text   =   ds.Tables[ "table1 "].Rows[6][ "cNation "].ToString();
                                txtXueli.Text   =   ds.Tables[ "table1 "].Rows[7][ "cXueli "].ToString();
                                txtVisage.Text   =   ds.Tables[ "table1 "].Rows[8][ "cVisage "].ToString();