In my Grid view fileds like this:
BankName Branch AccNo Balance Edit Delete
ICCi
Sbi hyd 1231 2312 edit delete
Suppose I click Delete button the record will delete succesfully.
I can write like this:
--------------------------------------------------
cmd.Connection = conn;
cmd.CommandText = "DELETE FROM bank WHERE bankId='" + ResultGridView.DataKeys[e.RowIndex].Values[0].ToString() + "'";
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
how can I do for below showing?
Suppose I click the Edit ,the corresponding data will show like this:
Bankname :sbi(web controls)
Branch :hyd(same)
Accno 123(same)
Balance 123(same)
Nilanka DharmadasaPosted Nov 5, 2009, 12:50 AM
Use following code.
cmd.Connection = conn;
//myGridView is the name of your girdview.
GridViewRow row = myGridView.SelectedRow;
"UPDATE bank set
Bankname = '" + row.Cells[0].Text + "', Branch = '" + row.Cells[1].Text + "', Accno = '" + row.Cells[2].Text + "', Balance = " + row.Cells[3].Text + "
WHERE bankId='" + ResultGridView.DataKeys[e.RowIndex].Values[0].ToString() + "'";
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
If my answer helps you, please accept my answer.