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();
}

VulpesPosted Feb 15, 2014, 7:31 PM
http://www.c-sharpcorner.com/Forums/Thread/245848/condition-is-not-satisfying.aspx
Sathya NarayanPosted Feb 15, 2014, 3:12 AM
VulpesPosted Feb 12, 2014, 4:23 PM
private void DataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
DataGridViewRow row = new DataGridViewRow();
row = DataGridView3.Rows[e.RowIndex];
// Will put the value of the first column of the selected row into the textbox
label14.Text = row.Cells[0].Value.ToString();
txtsn.Text = row.Cells[1].Value.ToString();
txtsem.Text = row.Cells[2].Value.ToString();
cbosub.Text = row.Cells[3].Value.ToString();
rdbtn_present.Checked = row.Cells[4].Text;
rdbtn_absent.Checked = row.Cells[4].Text;
if (row.Cells[4].Text.Equals("Present"))
rdbtn_present.Checked = true;
else
rdbtn_present.Checked = false;
if (row.Cells[4].Text.Equals("Absent"))
rdbtn_absent.Checked = true;
else
rdbtn_absent.Checked = false;
Btn_Save.Enabled = false;
Btn_Modify.Enabled = true;
label14.Text = "";
label6.Text = "";
label5.Text = "";
label11.Text = "";
}
Sathya NarayanPosted Feb 12, 2014, 4:06 AM
VulpesPosted Feb 11, 2014, 9:37 AM
Not sure what you mean about the values being passed as an integer. If you're going to assign them to the Text property of a Label or TextBox, then they'll need to be in string format anyway which is what the ToString() method gives you.
Sathya NarayanPosted Feb 11, 2014, 12:22 AM
Sathya NarayanPosted Feb 11, 2014, 12:17 AM
VulpesPosted Feb 10, 2014, 4:20 PM
JobPencilPosted Feb 10, 2014, 7:37 AM
Try This Link It May Help You.
http://social.msdn.microsoft.com/Forums/windows/en-US/3bfb7fbf-0dc0-4540-b712-625acd09784c/passing-data-back-to-called-form?forum=winformsdesigner
http://www.jobpencil.com