rashmi kc

rashmi kc

  • NA
  • 113
  • 159.4k

Grid view in windows form c#

Jul 17 2012 2:30 PM
I am having a grid view when i double click on the row its  value  should display in the text box and combobox respectively   but m getting error and its not displaying ...
Pls  help me  ...
Here s my code


        private void dataGridView1_DoubleClick(object sender, EventArgs e)
          {
            try
            {
                DataTable dt = new DataTable();
                OleDbDataAdapter da = new OleDbDataAdapter("select class_standard,subjectcode,subjectname from tblsubject where subjectcode=" +
             Convert.ToInt16(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()) + " ", con);
                da.Fill(dt);
                //display now the record in the textbox

              textboxsubcode.Text = dt.Rows[0][0].ToString();
              textboxsubname.Text = dt.Rows[0][1].ToString();
                cmboboxclass.Text = dt.Rows[0][2].ToString();


            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToString());

            }

        }


Answers (3)