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


JobPencil56 reputationPosted Feb 10, 2014, 2:37 AM EST
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
VulpesRank #55 · 29.2K reputationPosted Feb 10, 2014, 11:20 AM EST
Sathya Narayan148 reputationPosted Feb 10, 2014, 7:17 PM EST
Sathya Narayan148 reputationPosted Feb 10, 2014, 7:22 PM EST
VulpesRank #55 · 29.2K reputationPosted Feb 11, 2014, 4:37 AM EST
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 Narayan148 reputationPosted Feb 11, 2014, 11:06 PM EST
VulpesRank #55 · 29.2K reputationPosted Feb 12, 2014, 11:23 AM EST
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 Narayan148 reputationPosted Feb 14, 2014, 10:12 PM EST
VulpesRank #55 · 29.2K reputationPosted Feb 15, 2014, 2:31 PM EST
http://www.c-sharpcorner.com/Forums/Thread/245848/condition-is-not-satisfying.aspx