Hey... I have dataGridView and button „Edit“ for editing informations of the dataGridView and now I'm trying to read the informations in the firts form, and write them in to the second form but when I clicked on the „Edit“ button I get error message „Input string was not in a correct format“ and the informations in the second form are given in a random order (e.g First name: 223548745, Last Name: New York, Home Number: John) :/
Here is my code:
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
string queryString = "SELECT FirstName, LastName, HomeNumber, MobileNumber, eMail, WebSite FROM Friends";
int currentRow = int.Parse(e.RowIndex.ToString());
try
{
/* I mean this is incorrect */
string friendsIDString = dataGridView1[0, currentRow].Value.ToString();
friendsIDInt = int.Parse(friendsIDString);
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
// Funkcija za dugmeto "Promeni"
if (dataGridView1.Columns[e.ColumnIndex] == editButton && currentRow >= 0)
{
string firstName = dataGridView1[1, currentRow].Value.ToString();
string lastName = dataGridView1[2, currentRow].Value.ToString();
string homeNumber = dataGridView1[3, currentRow].Value.ToString();
string mobileNumber = dataGridView1[4, currentRow].Value.ToString();
string eMail = dataGridView1[5, currentRow].Value.ToString();
string webPage = dataGridView1[6, currentRow].Value.ToString();
// Start Form for Editing
EditFriends frmEditFriends = new EditFriends();
frmEditFriends.firstName2 = firstName;
frmEditFriends.lastName2 = lastName;
frmEditFriends.homeNumber2 = homeNumber;
frmEditFriends.mobileNumber2 = mobileNumber;
frmEditFriends.eMail2 = eMail;
frmEditFriends.webPage2 = webPage;
frmEditFriends.friendsID2 = friendsIDInt;
frmEditFriends.Show();
dataGridView1.Update();
}
....
....
Thanks...