Sathya Narayan

Sathya Narayan

  • NA
  • 146
  • 48k

passing values to one form to another form

Feb 10 2014 7:18 AM
hi,

I am passing the values from one form to another using datagridview.In form1 i have taken 2textboxs and in form2 i have taken the datagridview.Which hasn't been binding the values to the textboxes.Can anyone help me???

Here is code.

 private void Display()
        {
            SqlConnection con = new SqlConnection(connectionString);
            DataTable dt = new DataTable();
            SqlDataAdapter sda = new SqlDataAdapter("SELECT slno,sname,deptid,Department from Student_View where stu='A' order by sname", con);
            sda.Fill(dt);
}

 private void DataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            SemisterUpgradeMaster r = new SemisterUpgradeMaster();
            DataGridViewRow row = new DataGridViewRow();
            row = DataGridView3.Rows[e.RowIndex];

            // Will put the value of the first column of the selected row into the textbox
            r.label2.Text = row.Cells[0].Value.ToString();
            r.txtsn.Text = row.Cells[1].Value.ToString();
            r.txtdep.Text = row.Cells[3].Value.ToString();
            this.Close();
           
        }
 

Answers (9)