private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string id = ((TextBox)e.Item.Cells[1].Cont rols[0]).Text;
string un = ((TextBox)e.Item.Cells[2].Cont rols[0]).Text;
string uf = ((TextBox)e.Item.Cells[3].Cont rols[0]).Text;
string password = ((TextBox)e.Item.Cells[4].Cont rols[0]).Text;
string email = ((TextBox)e.Item.Cells[5].Cont rols[0]).Text;
SqlConnection conn =
new SqlConnection("server=(local);uid=sa;p wd=yaali;database=MDB;");
// Prepare the command text
String strCmd = "UPDATE tblPrimary SET password='"+
password+ "'" + "email='" + email+ "'"+
" WHERE id=" + id;
SqlCommand cmd = new SqlCommand(strCmd, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
// Reset the edit mode for the current item
DataGrid1.EditItemIndex = -1;
// create data source again.........
bindToDatGrid("id");
}